Câu hỏi của tôi là khá tiểu học, nhưng tôi không hiểu tại sao, trong đoạn mã sau, vào nút bấm duy nhất dissapears nút, thay vì toàn bộ div:javascript - loại bỏ yếu tố
<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>
+1 Có, đó là lời giải thích khá tốt. Cảm ơn rất nhiều!! Tôi sẽ chấp nhận nó trong vòng vài phút. – JosephConrad
Tại sao nút 'remove' của nút được gọi? Có một số ẩn chứa 'with' trong hành động? Và 'cái này' đến từ đâu? Nó không phải là một phương thức DOM được chỉ định. –
Tôi đã thấy hành vi này một thời gian trở lại và không bao giờ thực sự đặt câu hỏi đó. – Musa