且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何知道哪一行选择了哪个单选按钮ID?

更新时间:1970-01-01 07:58:48

要获取行ID和已检查单选的值,请使用以下命令:

To get the row id and the value of checked radio, use this:

$('#list').on('click','.addClickClass',function(){
     alert($(this).parents('li[id*="tc"]').attr('id') + "\n" 
         + $(this).parents('.ui-collapsible').find('input:checked').val())
 })

它为您提供了这样的输出,例如:

It gives you output like this, for example:

tc_1
TestCommand

我相信这正是您想要的.

which I believe is exactly what you're looking for.

我用它来获取行ID:

$(this).parents('li[id*="tc"]').attr('id')

,以获取检查的单选值:

and this to get the checked radio value:

$(this).parents('.ui-collapsible').find('input:checked').val()

两者都与单击的添加"按钮有关.

Both related to the clicked Add button.

在此处查看其运行情况: http://jsfiddle.net/R2DzV/16/

See it in action here: http://jsfiddle.net/R2DzV/16/