为什么$(文件)。我没有为我开火? [英] Why is $(document).ready not firing for me?

查看:166
本文介绍了为什么$(文件)。我没有为我开火?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在php文件中,我使用 include 来包含以下js.php文件
,在此之前我已经包含了jquery文件。

In a php file i have used include to include the following js.php file and prior to that i have included the jquery file.

<script type="text/javascript">

$(document).ready(function(){
     alert("hello");
});
</script>

但它不起作用。为什么?当我跳过$(document).ready函数时它会工作。

But it doesn't work. Why? when I skip the $(document).ready function it works.

但是我需要jquery代码。有什么问题?

But i need jquery code inside. what is wrong?

推荐答案

根据你的说法,最可能的答案是核心jQuery文件实际上并不是正确包含在页面中。
你需要这样的东西:

The most likely answer, based on what you have said, is that the core jQuery file is not actually included correctly in the page. You need something like:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

有可能丢失或输入错误。

Chances are, this is missing or typed incorrectly.

这篇关于为什么$(文件)。我没有为我开火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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