A quick question about jQuery’s each() function;
When I use each(), it’s usually because I want to affect all the elements apart from just one. For instance:
$("a.aboutMenu").each(function () {
$(this).css("color","#FFF");
});
$(this).css("color","#111");
Is there a shorthand way of writing this better? I realise I could put an if in the each function, but there must be someway of writing “each except $(this)“?
Is exactly the same thing if you see on the jQuery API.
In your example you are saying: for each a.aboutMenu to change the css color to be white.
You can also write:
If you need a control just add an
ifinside your function.EDIT:
To remove just
thiselement you can write:or better: