为什么我不能使用 jQuery 功能

Why I cant use jQuery functionality

我在 /opt/lampp/htdocs 目录中有 jquery-2.1.3.js 库,为了测试它,我将它包含在 html 文件中

<html>
    <body>
        <p>Some paragraph</p>
        <script src="jquery-2.1.3.js">
            $("p").css("color","orange")
            $("body").css("background","#00ff00")
        </script>
   </body>
</html>

由此我希望将 </p> 标签内的所有文本更改为橙色并将 </body> 背景设置为绿色,但我得到的只是简单的输出:Some paragraph 默认颜色和默认背景。为什么这不起作用?

script elements 可以具有 src 属性 内容,但不能同时具有两者。如果两者都有,则忽略内容(内容被视为 "script documentation," 而不是代码)。

为您的 jQuery 脚本使用另一个脚本块

<script src="jquery-2.1.3.js">
</script>
<script>
    $("p").css("color","orange")
    $("body").css("background","#00ff00")
</script>