HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>We have now figured out how to hide those news stories whose category does not match the filter value. But there is a problem: if you toggle the filter several times, then all of the news stories will disappear from the page. Why does this happen?</p>
1 <p>We have now figured out how to hide those news stories whose category does not match the filter value. But there is a problem: if you toggle the filter several times, then all of the news stories will disappear from the page. Why does this happen?</p>
2 <p>The problem is that we told JavaScript when to add the hidden class, but did not say when to clear the value. If the filter value has changed, some news stories should be hidden while others will be shown again. But for the moment we only want to hide the news.</p>
2 <p>The problem is that we told JavaScript when to add the hidden class, but did not say when to clear the value. If the filter value has changed, some news stories should be hidden while others will be shown again. But for the moment we only want to hide the news.</p>
3 <p>We will make sure that only those news stories whose category matches the new filter value will be displayed on the page. Add the else branch to the conditional statement: if the condition is false, meaning that the news category is equal to the filter value, then the hidden class should be removed from it. After that, toggle the filter several times and make sure that the problem has gone away.</p>
3 <p>We will make sure that only those news stories whose category matches the new filter value will be displayed on the page. Add the else branch to the conditional statement: if the condition is false, meaning that the news category is equal to the filter value, then the hidden class should be removed from it. After that, toggle the filter several times and make sure that the problem has gone away.</p>