为什么我的脚本元素中的代码无法运行? [英] Why does my code in a script element not run?

查看:80
本文介绍了为什么我的脚本元素中的代码无法运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的smarty模板中包含以下脚本:

I have the following script in my smarty template:

<script src="http://code.jquery.com/jquery-latest.js">
    $(document).ready(myBookings);
</script>

但是,它不适用于页面加载.但是,当我在Mozilla firebug控制台中运行$(document).ready(myBookings);时,它确实可以工作.我在做什么错了?

However it doesn't work on page load. $(document).ready(myBookings); does work when I run it in Mozilla firebug console though. What am I doing wrong?

推荐答案

script elements can have a src attribute or content, but not both. 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>

这篇关于为什么我的脚本元素中的代码无法运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆