sorry for my english
I have this code :
no problem
How I can adapt the code when “select” is like this :
<select id="example[164]" name="example[164]" type="text" />
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<div class="test">
Some text...<br /><input type="checkbox" name="foobar" value="1" /><br />More text...
</div>`
Thanks for your help
:D)
This HTML is not valid except in HTML5. The characters
[]are not permitted in theidattribute, which should be letters, numbers, periods, hyphens, underscores, and colons.To match that invalid id with jQuery, you would need to escape the
[]with two backslashes:In context of your example, change
$('#example')to$('#example\\[164\\]')Later, it also appears as:
function(e) {
However, since this is not a valid id attribute (unless you are using HTML5), you should instead match on the element’s
nameattribute, and if this is being generated on the server side, instead change the id attribute to something valid like<select id='example_164'>.Here is the updated jsfiddle