Here’s my code:
<script type="text/javascript">
$('input[name="paymenttype"]').change(function () {
alert("works!"); // This doesn't fire.
});
</script>
<div id="paymentselector">
<label>
<input name="paymenttype" value="deposit" type="radio" />Deposito
</label>
<label>
<input name="paymenttype" value="creditcard" type="radio" />Tarjeta de Credito
</label>
</div>
According to the documentation, this should work:
http://api.jquery.com/attribute-equals-selector/
In the change() event, the alert isn’t fired.
Is something wrong in my Javascript code?
You could try adding a document ready handler –