开发者

selecting an array of elements in jQuery

开发者 https://www.devze.com 2023-02-12 02:27 出处:网络
I have a form set up like this in HTML: <input type=\"text\" name=\"data[type1][0]\" value=\"\" size=\"20\" id=\"data[type1][0]\"/>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号