I have many elements that are structured to get them in array like mapping on server side.
<input type="CHECKBOX" id="478" value="1" name="data[GroupInfo][student][478]" onclick="return updateValues('478')">
<input type="CHECKBOX" id="490" value="1" name="data[GroupInfo][student][490]" onclick="return updateValues('490')">
<input type="CHECKBOX" id="478" value="1" name="data[ClassInfo][student][478]" onclick="return updateValues('478')">
<input type="CHECKBOX" id="490" value="1" name="data[ClassInfo][student][490]" onclick="return updateValues('490')">
so on... Now, I want to select them using their name attribute like
$("[name^=data[ClassInfo][student]]");
but this won't work I tried to escape barckets to.
$("[name^=data\[ClassInfo\]\[student\]]");
but no luck;
I want to select them using name attribute.
Try:
// For exact element
$('input[name=data[GroupInfo][student][478]]');
Or
// For list of elements
$('input[name^=data[GroupInfo][student]]');
You can see more here
尝试这个:
$("[name^='data[ClassInfo][student]']");//Wrap in the single quotes
$('input[name*="data[ClassInfo][student]"]') // matches those that contain 'data[ClassInfo][student]'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.