问题:
I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked. 我可以将单选按钮设置为选中状态,但是我想做的是设置一种“侦听器”,当选中某个单选按钮时会激活它。
Take, for example the following code: 以下面的代码为例:
$("#element").click(function()
{
$('#radio_button').attr("checked", "checked");
});
it adds a checked attribute and all is well, but how would I go about adding an alert. 它添加了一个选中的属性,一切都很好,但是我将如何添加警报。 For example, that pops up when the radio button is checked without the help of the click function? 例如,在没有单击功能的情况下选中单选按钮时,会弹出该窗口吗?
解决方案:
参考一: https://stackoom.com/question/9XBL/找出JQuery是否选中了单选按钮参考二: https://oldbug.net/q/9XBL/Find-out-whether-radio-button-is-checked-with-JQuery
来源:oschina
链接:https://my.oschina.net/u/4437884/blog/4418032