我的问题很基础,但我不明白为什么在以下代码中,单击按钮时只有按钮消失了,而不是整个div消失了:
<script>
function remove(id) {
//get the element node
element = document.getElementById(id);
//remove the element from the document
document.removeChild(element);
}
</script>
<div id="intro" class="jumbotron">
<h1>Your Offline Web Dictionary!</h1>
<p class="lead">
<div class="controls">
<input class="span7 " type="text" placeholder=" " name="key">
</div>
<div>
<button class="btn btn-large btn-success" onclick="remove(intro)">
Dictionary Search
</button>
</div>
</div>
remove
函数?是否在动作中隐含了with
函数?还有,这个remove
函数从哪里来的?它不是指定的 DOM 方法。 - T.J. Crowderonclick
生成的函数中隐式使用元素的with
正在回来困扰我...) - T.J. Crowder