使用jQuery动态删除单选按钮

Jav*_*yer 2 javascript jquery

我有一个问题,删除单选按钮使用,我已经使用(.remove)功能,但当我使用它删除所有的单选按钮,我想删除它们separetly:在这里看到一个演示http://jsfiddle.net/HaBhk/10 / 谢谢

lin*_*asy 5

您可以通过id"类"或"特定" 分隔单选按钮tag names,然后适当选择它们并删除它们.

喜欢 :

$('input[type=radio].class_name').remove(); // delete with class_name
// or 
$('input[type=radio]#id_name').remove();  // delete with id_name
// or
$('input[type=radio][name=your_specific_name]').remove(); // delete with your radio button's specific name attribute.

$('input[type=radio]:eq(1)').remove(); //to remove your elements if they would occur in fixed specific order, or in case dynamic order deletion is fine.
Run Code Online (Sandbox Code Playgroud)

OP的评论更新

如果它们是动态生成的,它仍然可以完成,不知道你的动态语言是什么,但考虑一下php,你可以这样做:

$('input[type=radio]#<?php echo $dynamic_id_variable; ?>').remove();

//or for javascript
$('input[type=radio]#'+ dynamic_id_variable ).remove();
Run Code Online (Sandbox Code Playgroud)