selector on elements like id="name[2]"

selector on elements like id="name[2]"


Hi all,
Not sure if this is even relevant to the development side of the
group.
I've noticed if i have something such as:
<input type="text" name="firstname[1]" id="firstname[1]" />
<input type="text" name="firstname[2]" id="firstname[2]" />
And then i use a selector such as
$("#firstname[2]") then nothing is returned; In fact even
document.getElementsById('firstname[2]') will return nothing. I'm not
sure if it's being turned into an array internally or if i'm
misinterpreting how getElementById works but it's been bugging me.
I dont need a solution on how to select the element i already figured
I could do something like:
$("[id='firstname[2]']"); which works fine but what I am curious to
know is why the behavior is so odd for this type of id.
Thanks guys,
Much appreciated.