jQuery click event on radio button doesn't get fired

后端 未结 6 855
栀梦
栀梦 2021-01-01 14:27

I\'ve got the following code to trigger a click event on some radio buttons! but it doesn\'t get fired! can any one help me with this!

CODE :

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 15:19

    Personally, for me, the best solution for a similar issue was:

    HTML

    
    
    

    JQuery

    var $selectAll = $( "input:radio[name=selectAll]" );
        $selectAll.on( "change", function() {
             console.log( "selectAll: " + $(this).val() );
             // or
             alert( "selectAll: " + $(this).val() );
        });
    

    *The event "click" can work in place of "change" as well.

    Hope this helps!

提交回复
热议问题