How I can select a specific a element id whit jquery find?Or it is even possible?
HTML:
<div id="bar">
<a id="1" href="#"></a>
<a id="2" href="#"></a>
<a id="3" href="#"></a>
<a id="4" href="#"></a>
</div>
Javascript:
$('#bar a').find('id',2).css("background-color","blue");
But dosen’t work
IDs must be unique, so simply use
$('#2')to select the element. There is usually no need to make an ID selector more specific and doing so would just slow it down.Besides that, unless you are using HTML5, an ID cannot start with a number. Use e.g.
whatever-2instead of just2