There are many input radio elements on a web page and each radio element has several options. I want a function to be fired whenever one option of a radio element is checked. How to write the code using Jquery? One input element looks as follows:
<div class="below">
<input type="radio" value="information" name="option0"/>
information
<input type="radio" value="communication" name="option0"/>
communication
<input type="radio" value="goods" name="option0"/>
goods
<input type="radio" value="attention" name="option0"/>
attention
</div>
I wrote the code as follows:
$('input:radio').click(function () {
if (this.checked) { // or $(this).attr('checked')
alert(this.value); // or alert($(this).val());
}
});
My Jquery version is
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
I am using Firefox. On the error console it says "unknown pseudo-class or pseudo-element 'radio' ". Any idea? What's wrong?
My previous question is close to this question but I have not got a solution so far. So I have to ask around. Hope this question will not be closed as a duplicated question. Thank you!