You need to specify the name attribute:
var test = $("input[name='phone[]']:eq(0)");
because phone[] invalid name without quotes. Therefore, the JQuery (or DOM) parser simply ignores all the invalid ones and processes the selector as if it were just input[name='phone']:eq(0) . It's also worth noting that this behavior seems to be fixed in more modern versions of jQuery. You use the rather old version 1.6.4 in your demo, but if you check it with 1.8.x and higher, it will correctly execute the error.
For example, if you try
try { document.querySelector("input[name=phone[]]") } catch(e) { alert(e.message) }
he even gives an error
Uncaught SyntaxError: Failed to execute 'querySelector' in 'Document': 'input [name = phone []]' is not a valid selector.
But jQuery is more forgiving, and it just selects everything it can.
source share