jQuery:循环HTML表格中的所有单选按钮

Shy*_*yju 8 jquery radio-button

我有一个有n行的HTML表,每一行在Row中包含一个单选按钮.使用jQuery,如何通过这些单选按钮检查哪一个被检查?

Sun*_*nny 10

$('#table tbody tr input[type=radio]').each(function(){
 alert($(this).attr('checked'));
});
Run Code Online (Sandbox Code Playgroud)

HTH.

  • `#table> tr`会在某些浏览器(chrome/firefox)上窒息,这些浏览器喜欢添加自己的`tbody`元素,而`#table tr`则不会. (3认同)