我有一个示例代码
<script type="text/javascript">
function remove_news(id) {
try {
$('news_list').removeChild($('news_'+id));
$('news_list').removeChild($('input_news_'+id));
if($('news_list') == '') {
var input = document.createElement('input');
input.setAttribute("type", "hidden");
input.setAttribute("name", "news_id");
input.setAttribute("value", "0");
document.getElementById("news_list").appendChild(input);
}
} catch(err){}
}
</script>
<div id="news_list">
<div id='news_1'> News no 1 <a href='#' onclick='remove_news(1); return false;'>[Delete]</a></div>
<input type="hidden" id="input_news_1" name="news_id" value="1" />
</div>
当我运行代码时,选择删除链接结果不显示<input type="hidden" name="news_id" value="0" />
如何解决?