[英]why second time button click not work properly?
我在按钮click上进行了一行操作。第一次运行良好,请展开并检查.。但是,如果我第二次单击,它将与第一次操作不同。 http://jsfiddle.net/R2DzV/5/
$(document).ready(function(){
$('.btn_handler').click(function(){
$("#list").append('<li><div data-role="collapsible"><h3>name</h3><ul><li><div fieldset data-role="controlgroup" id="Smoker"><input type="radio" name="radio-choice" id="radio-choice-1" value="TestCase" checked="checked"><label for="radio-choice-1">Add Test Case</label><input type="radio" name="radio-choice" id="radio-choice-2" value="TestCommand"><label for="radio-choice-2">Add Test Command</label></fieldset>' + '<a data-role="button" data-mini="true" data-theme="a">Add</a></div></li></ul></div></li>');
$('#list').trigger('create');
$('#list').listview('refresh');
})
});
您的代码中生成了重复的ID。
删除id="Smoker"
并学习一些新知识:
<label><input type="radio" /> Click the text and the radio button gets it!</label>
将其替换为.append()
:
<div fieldset data-role="controlgroup" id="Smoker">
与:
<fieldset data-role="controlgroup" id="Smoker">
然后解决明显的问题,即您应该仅具有唯一的ID(也许可以使它们成为类)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.