Nested id in jQuery selector

I am trying to change the href for a nested in a div called blink3:

$('#blink3 #backLink').attr('href',"#item5");

If the html code is as follows:

<div style="float:left;text-align:center;" id="blink3">
<a href="#item4" class="panel" id="backLink">
<div class="divBack"></div></a>
</div>

works well in all browsers - NOT IE 7 , and I can not understand why, does not change href.

Is this a bug in IE 7? Jquery Is there something wrong with my code?

Any solutions?

+5
source share
3 answers

Nick Craver (omg, where have you been?) Already stated this in a comment. It is completely pointless to create a type selector #id #idbecause the identifier must be unique in your DOM by definition.

It looks like you are breaking this rule, and therefore jQuery may choose the wrong node.

" " id classes ,

$('#blink3 .backLink');
+19

, , . ID , . , . , , :

$("#parentId").find("#childId")
+3

. Nick, backlink. $('#backlink') . backlink, HTML- , .

+2

All Articles