How to trigger a click on checked radio button in jquery or javascript -


javascript:

if (getcookie('prev_radio_value')!=null){         alert(getcookie('prev_radio_value'));      $(":radio[value="+getcookie('prev_radio_value')+"]").attr('checked',true);      $(":radio[value="+getcookie('prev_radio_value')+"]").triggerhandler('click');       $(':radio:checked').triggerhandler('click');       $('input:radio[name=theme]:checked').click();      }else{         alert("clicking first");      $("input:radio:first").attr("checked", true).trigger("click");       } 

html code:

<ul>  <li><input type="radio"  name="theme" value="theme1"/>theme1</li>  <li><input type="radio"  name="theme" value="theme2"/>theme2</li>  </ul> 

this code inside div -> 'checkbox_div'

click function :

$("#checkbox_div input:radio").click(function() {   alert("clicked") ;  }); 

i have used trigger click in 3 ways none of them worked or triggered click event.

example link : http://jsbin.com/ezesaw/1/edit not triggering click event upon selection of first radio button.

it works fine:

http://jsbin.com/ivojoz/1/edit

the problem may not selecting radio correctly

try

$('#checkbox_div input[type="radio"]').click(function() {   alert("clicked") ;  }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -