$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - How do I disable and enable list items depending on the filter in jquery? - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How do I disable and enable list items depending on the filter in jquery? - Stack Overflow

matteradmin15PV0评论

Here is what I've created: /

I want to enable and disable the links depending on the filter - 'All Years' starts off disabled as all the years are showing - if I click on 2010 All years should bee enabled and so on.

<ul name="yearfilter" id="yearfilter">
<li value=""><a data-value="" href="#" class="disable">All years</a></li>
<li value="2011"><a data-value="2011" href="#">2011</a></li>
<li value="2010"><a data-value="2010" href="#">2010</a></li>
</ul>

Here is what I've created: http://jsfiddle/zidski/ktSA9/

I want to enable and disable the links depending on the filter - 'All Years' starts off disabled as all the years are showing - if I click on 2010 All years should bee enabled and so on.

<ul name="yearfilter" id="yearfilter">
<li value=""><a data-value="" href="#" class="disable">All years</a></li>
<li value="2011"><a data-value="2011" href="#">2011</a></li>
<li value="2010"><a data-value="2010" href="#">2010</a></li>
</ul>
Share Improve this question asked Nov 4, 2011 at 11:48 highchartsdudehighchartsdude 5713 gold badges10 silver badges16 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

I have updated your fiddle: http://jsfiddle/ktSA9/4/

Pertinent change:

$("#yearfilter a").removeClass("disable");
$(this).addClass("disable");

Something like this should do the trick:

$("#yearfilter a").bind('click', function() {
    $("#yearfilter a").removeClass('disable');
    $(this).addClass('disable');
});

EDIT: Changed the above to bind to the anchor elements instead of the list items.

Essentially you just need to add the following two lines to your existing function:

$("#yearfilter a").removeClass('disable');
$(this).addClass('disable');

Check this http://jsfiddle/ktSA9/2/

Post a comment

comment list (0)

  1. No comments so far