How Do i handle both the checked and clicked events in Jquery
- by Someone
Say I have a form and onload of that form I have 2 radio buttons say "yes" or "no "
I have set of action to perform when we select either one radio button .Say if we select "yes "
//Onload of Form
if(("#yes:checked")){
$("#table").show();
$("#div1").show();
$("#div2").show();
alert("Checkedd on Load");
}
//for click
$("#yes").bind('click',function(){
$("#table").show();
$("#div1").show();
$("#div2").show();
alert("Checked by Click"); });
});
Iam Writing the same repeated lines of code for two similar set of events .Is There anyway to combine the "Checked" and "Clicked" events
Say if i do inthis way than "Checked" doesnot get called untill "Clicked"?Is there any other way to do it.
$("#yes").bind('click',function(){
if(("#yes:checked")){
$("#table").show();
$("#div1").show();
$("#div2").show();
alert("Checked by Click");
}
});
});