You are supposed to add the javascript code in a $(document).ready(function() {});
(您应该将JavaScript代码添加到$(document).ready(function() {});
)
block.(块。)
ie(即)
$(document).ready(function() {
$("#clicker").click(function () {
alert("Hello!");
$(".hide_div").hide();
});
});
As jQuery documentation states: "A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready()
will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute"(正如jQuery文档指出的那样:“在文档“就绪”之前,无法安全地操纵页面。jQuery会为您检测到此就绪状态。 $( document ).ready()
包含的代码仅在页面Document Object运行一次模型(DOM)已准备就绪,可以执行JavaScript代码”) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…