[英]Why does my code in a script element not run?
I have the following script in my smarty template: 我的smarty模板中包含以下脚本:
<script src="http://code.jquery.com/jquery-latest.js">
$(document).ready(myBookings);
</script>
However it doesn't work on page load. 但是,它不适用于页面加载。
$(document).ready(myBookings);
does work when I run it in Mozilla firebug console though. 确实可以在Mozilla firebug控制台中运行它。 What am I doing wrong?
我究竟做错了什么?
script
elements can have a src
attribute or content, but not both. script
元素可以具有src
属性或内容,但不能同时具有两者。 If they have both, the content is ignored (the content is considered "script documentation," not code). 如果两者兼有,则将忽略内容(该内容被视为“脚本文档”,而不是代码)。
Use another script block for your document-ready handler 为您的文档就绪处理程序使用另一个脚本块
<script src="http://code.jquery.com/jquery-latest.js">
</script>
<script>
$(document).ready(myBookings);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.