click or change event on radio using jquery

后端 未结 5 1599
挽巷
挽巷 2021-02-06 19:49

I have some radios in my page,and I want to do something when the checked radio changes,however the code does not work in IE:

$(\'input:radio\').change(...);
         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 20:30

    Works for me too, here is a better solution::

    fiddle demo

    one
    two

    You must make sure that you initialized jquery above all other imports and javascript functions. Because $ is a jquery function. Even

    $(function(){
     
    }); 
    

    will not check jquery initialised or not. It will ensure that will run only after all the javascripts are initialized.

提交回复
热议问题