Please I have an input text and I want to add a class to it :
<input type="text" name ="var[1]" />
I tried this line but no success :
$('input[name=var[1]]').addClass('invalidField');
PS : This input does not exist in markup, but its displayed using ajax !
Use quotes and be sure to call it once the dom is ready :
The quotes are optional only when the value is “simple”. If it contains parenthesis, spaces, braces, etc., jQuery doesn’t get where the value ends and can’t parse the expression.