【问题标题】:php jquery in the include page包含页面中的php jquery
【发布时间】:2014-11-12 08:22:53
【问题描述】:

我目前遇到了 PHP 和 jQuery 的问题。我已经建立了一个这样的网站:

index.php

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test Page</title>
</head>
<body>
    include('content.php');
    <script src="js/jquery.min.js"></script>
</body>

内容.php

test
<script type="text/javascript">
    $(document).ready(function() {
        alert("Hello World");
    });
</script>

但是当页面加载时..警报不起作用..我错过了什么吗?

【问题讨论】:

  • 试试&lt;?php include('content.php'); ?&gt;而不是include('content.php');
  • 赞成。对于初学者来说,这实际上是一个很好的问题。 (但是引导程序在哪里?)

标签: javascript php jquery include


【解决方案1】:

你有两个问题:

  1. 包括('content.php');

这应该是

<body>
<?php include('content.php'); ?>
<script src="js/jquery.min.js"></script>
</body>
  1. 您在加载 jquery 之前触发了 jquery 代码。

像这样改变。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test Page</title>
    <script src="js/jquery.min.js"></script>
</head>
<body>
    <?php include('content.php'); ?>        
</body>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 2011-06-04
    • 1970-01-01
    • 2015-05-11
    • 2013-03-11
    相关资源
    最近更新 更多