Checking radio button with jQuery doesn't trigger radio's onclick event

前端 未结 1 832
轮回少年
轮回少年 2021-02-05 11:02

I have a pair of radios, to which I assign a function using bind(), on the pages .ready event. then, on the same ready event, I check for another input\'s value, and if it\'s va

1条回答
  •  伪装坚强ぢ
    2021-02-05 11:42

    Just trigger the click event when you set the checked attribute.

    $("#fpago2").attr('checked', true).trigger('click');
    

    Changing an attribute on the element doesn't fire a changed event... Neither by the native setAttribute or using jQuery's attr.

    0 讨论(0)
提交回复
热议问题