How to check a radio button with jQuery?

前端 未结 30 2471
独厮守ぢ
独厮守ぢ 2020-11-22 08:12

I try to check a radio button with jQuery. Here\'s my code:

30条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 09:01

    Surprisingly, the most popular and accepted answer ignores triggering appropriate event despite of the comments. Make sure you invoke .change(), otherwise all the "on change" bindings will ignore this event.

    $("#radio_1").prop("checked", true).change();
    

提交回复
热议问题