<!DOCTYPE html<
<html<
<head<
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"<
</script<
<script<
$(document).ready(function(){
$("#button").click(function(){
var curAns="Radio 1";
var curVal=$('.optionAnswer:checked').val();
if(curAns == curVal)
{
$('.optionAnswer:checked').parent().append('<img width=25 height=25 src="" alt="correct"/<');
}
else
{
$('.optionAnswer:checked').parent().append('<img width=25 height=25 src="" alt="worng"/<');
$('.optionAnswer').each(function(index){
if($(this).val()== curAns)
$(this).parent().append('<img width=25 height=25 src="" alt="correct"/<');
});
}
});
});
</script<
</head<
<body<
<div id="optionAns")<
<span< <input type="radio" name="optionGroup" value="Radio 1" class="optionAnswer"<Radio 1</input<</span<</br<
<span< <input type="radio" name="optionGroup" value="Radio 2" class="optionAnswer"<Radio 2</input<</span<</br<
<span< <input type="radio" name="optionGroup" value="Radio 3" class="optionAnswer"<Radio 3</input<</span<</br<
</div<
<input type="button" id="button" name="button" value="submit" /<
</body<
</html<
<html<
<head<
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"<
</script<
<script<
$(document).ready(function(){
$("#button").click(function(){
var curAns="Radio 1";
var curVal=$('.optionAnswer:checked').val();
if(curAns == curVal)
{
$('.optionAnswer:checked').parent().append('<img width=25 height=25 src="" alt="correct"/<');
}
else
{
$('.optionAnswer:checked').parent().append('<img width=25 height=25 src="" alt="worng"/<');
$('.optionAnswer').each(function(index){
if($(this).val()== curAns)
$(this).parent().append('<img width=25 height=25 src="" alt="correct"/<');
});
}
});
});
</script<
</head<
<body<
<div id="optionAns")<
<span< <input type="radio" name="optionGroup" value="Radio 1" class="optionAnswer"<Radio 1</input<</span<</br<
<span< <input type="radio" name="optionGroup" value="Radio 2" class="optionAnswer"<Radio 2</input<</span<</br<
<span< <input type="radio" name="optionGroup" value="Radio 3" class="optionAnswer"<Radio 3</input<</span<</br<
</div<
<input type="button" id="button" name="button" value="submit" /<
</body<
</html<
No comments:
Post a Comment