Reputation: 5
Hy guys I would show my div when click on value radio button. My Html:
<form id="risp">
<input id="ris1" type="radio" name="ris" value="err1"> <label class="answer">0</label>
<input id="ris2" type="radio" name="ris" value="err1"> <label class="answer"> 2</label>
<input id="ris3" type="radio" name="ris" value="correct1"> <label class="answer">5</label>
</form>
<div id="correct">
<p>answer correct</p>
</div>
So I try this function:
$("#ris3").click(function () {
$("correct").show();
but don't function!!Why?? Thanx
Upvotes: 0
Views: 101
Reputation: 16223
It's because:
$('correct')
Should be:
$('#correct')
The problem is that your selector is wrong. Keep in mind a selector like $('correct')
would be looking for a <correct>
element which does not exist. For IDs, you have to use #
and .
for classes either one before the actual value. You can find more information on jQuery selectors here: http://api.jquery.com/category/selectors/
Note: as Stuart Kershaw mentioned on the comment below, remember to close your click function, otherwise it won't work...
Upvotes: 3