jQuery selectors with non-unique IDs

Testing how jQuery handles element IDs which are unique within a context but not the overall document. Result should display "Passed" if the browser was able to select the correct element within each context. Each item should also highlight in red on mouseover.

by alano

HTML

<fieldset id="set1">
    <legend>Non-Unique ID's:</legend>
    <div id="part1"><span id="item"></span></div>
    <div id="part2"><span id="item"></span></div>
    <div id="part3"><span id="item"></span></div>
</fieldset>
<fieldset id="set2">
    <legend>Unique (no) ID's:</legend>
    <div><span></span></div>
    <div><span></span></div>
    <div><span></span></div>
</fieldset>
<button id="test1">Sequential</button>

JavaScript

$("#test1").click(function(){
    var $set1 = $("#set1");
    $("#item", $set1).each(function(i,e){
        $(this).text("Index = " + i);
    });
    var $set2 = $("#set2");
    $("span", set2).each(function(i,e){
        $(this).text("Index = " + i);
    });
});