【问题标题】:How to selector ID textbox array using jquery如何使用 jquery 选择 ID 文本框数组
【发布时间】:2012-10-10 00:15:41
【问题描述】:

我有代码 HTML

<input id="info[text1]" type="text" value="1"/> <br>
<input id="info[text2]" type="text" value="2"/> <br>

我想使用 jquery 选择 id='info[text1]' 但我不能,所以你能帮帮我吗!

【问题讨论】:

标签: jquery jquery-selectors selector textinput


【解决方案1】:

你必须用\\转义括号

$("#info\\[text1\\]")

http://api.jquery.com/category/selectors/(第二段)

【讨论】:

  • 使用 PHP EOT 你需要 3 个反斜杠 \\\
【解决方案2】:

试试这个方法。

$('input[id="info[text1]"]')

【讨论】:

  • 为我工作,在input 之前添加冒号,效果更好;) $(':input[id="info[text1]"]') - 不错!
【解决方案3】:

试试这个:

$('#info\\[text1\\]');

http://jsfiddle.net/UwrVn/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多