开发者

Multiple toggle jquery

Could you help me pls with one problem? I need to multiple selection of categories for the same time as well as 'All' button which will toggle all elements.

Here is some code:

 $(function() {
//All Category  开发者_高级运维
  $('#5').click(function(){
  $('ul.thumbs').toggle();}); 
//First Category
  $('#6').click(function(){
  $('a.6').toggle();});
//Second Category
  $('#7').click(function(){
  $('a.7').toggle();});
//Third Category
  $('#8').click(function(){
  $('a.8').toggle();});
    }); 

And here is link example:

<a class="6"><img src=""></a>

I.e. in a class I store category number. Now it works not so proper. When you clicking by category link, it appear or disappear rightway. But when you clicking by 'All' link, it enable/disable only categories which wasn't toggled earier. I'm not jquery guru and don't think that I'll find some decisions by myself. Any help will be appreciate.


At first you shouldn't start the class name and the ids with a number.

Now, toggle hides visible items and shows hidden ones. When you toggle all elements, the elements that were previously hidden will be shown. Perhaps you need to replace toggle with hide() and show(), depending on what you are trying to achieve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜