How to connect radioButton
<input type radio .. />
to call function when is checked ? I need to record value of that button when it is checked.
js:
<script>
function yourfunction()
{
//function
}
</script>
<input id = "radio1" type = "radio" onclick = "yourfunction()" />
jQuery:
<script>
$( '#radio1' ).click(function(e)
{
//function
});
</script>
<input id = "radio1" type = "radio" />
You can add condition to check if the radio is chcecked or not, would look like
if ($( '#radio' ).attr('checked') == 'true')
{
}
as you can see in the fiddle
html:
<input type="radio" value="Test 1" /> Bullet 1 <br />
<input type="radio" value="Test 2" /> Bullet 2 <br />
<input type="radio" value="Test 3" /> Bullet 3 <br />
<input type="radio" value="Test 4" /> Bullet 4 <br />
js:
$(document).ready(function() {
$("input").click(function() {
if ($(this + ":checked")) {
alert($(this).val());
}
});
});