Reputation: 7956
function switch01(){
$("#contact").hide();
$("#about").hide();
$("#mail").hide();
};
This works, but I want all the three lines write in a single one.
I tried with +
and ,
- without result.
In fact I have five divs to hide.
Upvotes: 1
Views: 2631
Reputation: 10258
You can comma seperate your answer like this
$("#contact, #about, #mail").hide();
Example is here
I would normally use a class for this however such as hidden
<div id="contact" class="hidden">contact</div>
<div id="about" class="hidden">about</div>
<div id="mail" class="hidden">mail</div>
$(".hidden").hide();
Upvotes: 5
Reputation: 4592
See this : http://api.jquery.com/multiple-selector/
$("#contact,#about,#mail").hide();
should work
Upvotes: 13