i have this code below to show different divs when i choose certain radio buttons:
if ($("input[@name='exerciseRB']:checked").val() == 'New') {
$("#newExercise").show();
$("#existingExercise").hide();
}
else {
开发者_C百科$("#newExercise").hide();
$("#existingExercise").show();
}
at first, i just had two radio buttons (both named exerciseRB and everything works fine.
Now, later in my web page i added two new radio buttons (with the name lessonRB).
The issue is that once i added these other new radio buttons when i look up this in firebug:
$("input[@name='exerciseRB']:checked")
i actually get an array back with both the exerciseRB item as well as the lessonRB item. Its almost as if the
@name='exerciseRB'
is being ignored. any ideas here?
You don't need the @ before name in your selector.
@name='exerciseRB' should be name=exerciseRB ie:
$("input[name=exerciseRB]:checked")
精彩评论