selecting an array of elements in jQuery
I have a form set up like this in HTML:
<input type="text" name="data[type1][0]" value="" size="20" id="data[type1][0]"/>
<input type="text" name="data[type1][1]" value="" size="20" id="data[ty开发者_如何学编程pe1][1]"/>
I set up this way so $_POST['data'] would become an array in php.
Are there ways to select specific elements or the whole set of elements in jQuery?
I've tried
$("#data[type1][0]").css("visibility","visible");
but it doesn't work does not work.
Thanks in advance!
Brackets are jQuery meta-characters, you must escape them with two backslashes:
$("#data\\[type1\\]\\[0\\]").css("visibility","visible");
You need to double-escape the brackets
$("#data\\[type1\\]\\[0\\]").css("visibility","visible");
Also, [ and ] are invalid characters in the id-attributes in HTML4/XHTML.
精彩评论