jquery - How can I Bind one Selector and event to a radio button -
i editing question have "radio2" checked default on loading document. after user can select "radio1".
i have 2 parts of code:
handle when checked
if($("#radio2:checked") && $("#somehidden").val()==="abc") { //do set of actions $("#txt1").val("bcd"); $("#txt2").val("zxy"); } handle when clicked
$("#radio2").bind('click',function(){ if($("#somehidden").val()==="abc") { $("#txt1").val("bcd"); $("#txt2").val("zxy"); } }); i have written first part of code on load document have same set of actions , these actions appear same when click have seen in second part of code. question have remove first part of code why because have hidden value condition on click. how can handle both? using trigger() select it. don't want that.
use trigger trigger event.
$("#radio1").bind('click',function(){ alert("checked"); }).trigger('click'); //on ready;
Comments
Post a Comment