javascript jquery radio button click

前端 未结 6 1187
刺人心
刺人心 2020-12-04 20:23

I have 2 radio buttons and jquery running.

 first


        
6条回答
  •  借酒劲吻你
    2020-12-04 21:22

    If you have your radios in a container with id = radioButtonContainerId you can still use onClick and then check which one is selected and accordingly run some functions:

    $('#radioButtonContainerId input:radio').click(function() {
        if ($(this).val() === '1') {
          myFunction();
        } else if ($(this).val() === '2') {
          myOtherFunction();
        } 
      });
    

提交回复
热议问题