我希望在其名称中添加已编号的输入(已成功完成),但如果为空(无法),也可以通过单击按钮将其删除。使用此代码,所有搜索类别的输入都将被删除。我只想要空的部分被删除。这里是我的尝试:单独删除输入
<script type="text/javascript">
// contains the counter for elements added
window.__buttonClickCounter = 1;
// Keep reference to container
var c = document.getElementById('inputs');
// Click handler that appends to the contents of the container
var clickhandler = function() {
c.innerHTML = c.innerHTML + "<input class='search' style='margin-bottom:4px;' type='search' name='word" + window.__buttonClickCounter + "'/>";
window.__buttonClickCounter++;
$('#removebtn').click(function() {
$('.search').remove();
});
}
</script>
谢谢!
你使用jQuery? – 2013-03-20 06:26:31
当removebtn被点击时你将如何知道哪些输入已被删除 – 2013-03-20 06:27:11