Reputation: 76
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.
Upvotes: 1
Views: 330
Reputation: 104168
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.
Upvotes: 1