JQuery selector returns duplicate elements in Safari

I have a jQuery selector that queries elements by name and tag class. In a query that I expect to return three elements, Safari (v3.1.1 for Windows) returns an additional element.

The reason appears to be the numeric identifier *. Changing the identifier to non-numeric excludes the duplicate element. Oddly enough, changing the identifier of the first element to other numbers has an apparent random effect on the final result. Identifier 4 increases the number of results to five. 0, 9, and 1234 all return four elements.

<div class="mydiv" id="1"></div>
<div class="mydiv" id="2"></div>
<div class="mydiv" id="3"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
    $(function()
    {
        var div = $('div.mydiv');
        alert( div.length );                // Safari 3.1.1 returns 4
        alert( $.unique( div ).length );    // Safari 3.1.1 returns 3
    } );
</script>

Firefox 3 and IE 7 display 3 in both warning blocks.

* , HTML. jqGrid, , . , , .

, jqGrid. , , .

+3
1

: HTML. ( , , 95% )

, , , .. ... , , ... .

+6

Source: https://habr.com/ru/post/1734966/


All Articles