I have got a simple HTMl form with one field as follows:
<input type="text" name="data['User']['user_id']" id="data['User']['user_id']" value="1">
$(document).ready(function(){
$("#data['User']['user_id']").mouseover(function(){
alert("hello");
});
});
The code couldn’t work,
I think it may be the name of the Input text field that caused the problem,
but I don’t know how to alter it
because this is the naming convention in CakePHP.
The jQuery documentation has the answer:
So in your case:
$("input[name=\\[User\\]\\[user_id\\]]")Note though that I think the HTML snippet you posted is bogus. By default the Cake form helper creates elements like this:
The name does not contain any
'and the id is camelCased to be easily selectable.