I am trying to select this checkbox and test if it is checked
<input class="controls" id="user_regret_avatar" label="Delete My Picture" name="user[regret_avatar]" type="checkbox" value="1">
with this
if $("#user_regret_avatar").attr('checked') {
alert("yay");
}
else{
alert("aww");
};
but I am getting
Uncaught SyntaxError: Unexpected identifier
is my selector bad?
also note – I’ve seen http://api.jquery.com/prop/, I’ve checked all the checked tests.. still same issue
Now with fiddle – Can’t get the test going
You need to change the if condition as follows :
Note the
()after if:Here is a working JSFiddle