jQuery多维数组名称选择器

时间:2021-03-28 21:27:52

Hi i'm trying to select a form input by name, however my form is setup to post into a multi-dimensional array

您好我正在尝试按名称选择表单输入,但我的表单设置为发布到多维数组

I'm trying to use

我正在尝试使用

$('input[name=address[permanent][street]]')

to select the element but get the following response

选择元素但得到以下响应

Uncaught Error: Syntax error, unrecognized expression: input[name=address[permanent][street]]

未捕获错误:语法错误,无法识别的表达式:输入[name = address [permanent] [street]]

Is this at all possible?

这是可能吗?

3 个解决方案

#1


6  

Try use $('input[name="address[permanent][street]"]') or $('input[name="'+ index +'"]') in your loop

尝试在循环中使用$('input [name =“address [permanent] [street]”]')或$('input [name =“'+ index +'”]')

#2


0  

try this

var strAddress=address[permanent][street];
$('input[name='+strAddress+']')

updated

$('input[name="address[permanent][street]"]')

if your name of input is address[permanent][street]

如果你输入的名字是地址[永久] [街道]

#3


0  

Use the starts with selector: '[name^="address"]'

使用带选择器的开头:'[name ^ =“address”]'

#1


6  

Try use $('input[name="address[permanent][street]"]') or $('input[name="'+ index +'"]') in your loop

尝试在循环中使用$('input [name =“address [permanent] [street]”]')或$('input [name =“'+ index +'”]')

#2


0  

try this

var strAddress=address[permanent][street];
$('input[name='+strAddress+']')

updated

$('input[name="address[permanent][street]"]')

if your name of input is address[permanent][street]

如果你输入的名字是地址[永久] [街道]

#3


0  

Use the starts with selector: '[name^="address"]'

使用带选择器的开头:'[name ^ =“address”]'