javascript - jQuery 只能在 .html 文件中工作,而不能在 .PHP 文件中工作?

标签 javascript php jquery html

我有一个 HTML 文件,其中有一个简单的 jQuery 高亮效果。

这很好用。但是,当我将文件的扩展名从 .html 更改为 .php 并将其上传到我的服务器时,它不起作用。

它不起作用,我的意思是它没有突出显示 Div。

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style>
div {
width: 100px;
height: 100px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="hflip.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="counter"></div>
<form>
<input name="ajaxlink" type="button" id="ajaxlink" class="ajaxlink" />
</form>
<script>
$( '#ajaxlink' ).click(function() {
$( "#counter" ).effect( "highlight", "slow" );
});
</script>
</body>
</html>

我做错了什么?为什么它在 HTML 文件中工作正常而在 .PHP 文件中却不能?

最佳答案

没有<body> (开放标签)。并两次包含 jquery

关于javascript - jQuery 只能在 .html 文件中工作,而不能在 .PHP 文件中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19159669/

相关文章:

javascript - jQuery 匿名函数的 ESLint 错误

php - MySQL 到 DB2 通过 ADOdb PHP

javascript - 拆分器不适用于 &lt;iframe&gt; 或 <object>

javascript - jQuery .hide(),然后是基于文本输入的 .show()

javascript - Bootstrap : More Elegant way to move a div on scroll

javascript - 无法弄清楚为什么我的 change(...) 事件处理程序在这种情况下不起作用

javascript - 构建 Angular2 组件库的最佳方法是什么?

php - 一张表格响应,添加多个表格行

php - 数据库提交时不更新值

jquery - jQuery 中的 2+(多封)电子邮件验证文本输入