MBurak Erman MBurak Erman - 1 year ago 68
jQuery Question

How to change given input radio value with Jquery?

I have a basic radio button and want to change its value. I tried this but it did not work. It gave me an

[object Object]

<input type="radio" name="myname" value="horse">

var myval = $("input:radio").val(["cat"]);

How can I do it?

Answer Source


var myval = $("input:radio").val("cat"); // remove []
alert(myval.val()); // alert the value, not the jquery selector
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download