+ 6
How to add multiple ids to a jquery tag
window.onload = moveHide(); function moveHide(){ $(function(){ $("#left").fadeToggle(0); }); $(function(){ $("#right").fadeToggle(0); }); $(function(){ $("#down").fadeToggle(0); }); $(function(){ $("#up").fadeToggle(0); }); $(function(){ $("#square").fadeToggle(0); }); } This is my code currently but it’s really wrong and there has to be a way to make it shorter. window.onload = moveHide(); function moveHide(){ $(function(){ $("#HOW TO PUT MULTIPLE IDS HERE").fadeToggle(0); });
4 Antworten
+ 15
resolved !
$("#left,#right,#down,#up,#square").fadeToggle(0);
+ 2
Thanks @Ranjan
0
Use classes instead of IDs. An ID is supposed to be unique to a single element, but a class can be used on multiple elements.
In jQuery and CSS you use . instead of # to select a class.
0
thanks!