我无法在窗口中运行代码,.load(browser.jQuery())对我不起作用。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DOM AND WINDOW LOADED</title>
<script src="http://10.0.1.53/sandbox/jquery_files/js/jquery-2.1.4.min.js"></script>
<script src="text/javascript">
jQuery(window).load(function()
jQuery("#sample").html("Height= " + jQuery('#img1').height() + "<br>" + "Width= " + jQuery('#img1').width());
});
</script>
</head>
<body>
<div id="sample">
<img src="http://10.0.1.53/sandbox/jquery_files/images/JR01441-WGP900_1_lar.jpg" id="img1"/>
</div>
</body>
</html>发布于 2015-07-21 12:20:36
我将使用此技术来代替:
jQuery(document).ready(function() {
console.log( "ready!" );
});
参考:https://learn.jquery.com/using-jquery-core/document-ready/
原因是当窗口加载时,DOM是不可访问的,DOM也必须被处理。这就是为什么我们等待‘文档’准备就绪的原因(DOM:文档对象模型)
希望这能有所帮助:)
发布于 2015-07-21 12:25:47
它不是
<script src="text/javascript">它应该是
<script type="text/javascript">是的,您的jQuery(window).load(function()中缺少{
发布于 2015-07-21 12:40:44
函数后缺少大括号
jQuery(window).load(function() { ** missing **
** code here **
});https://stackoverflow.com/questions/31530290
复制相似问题