我的jQuery没有链接正确 [英] My jQuery Isn't Linked Properly

查看:72
本文介绍了我的jQuery没有链接正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个网站上有很多相同标题的帖子,但没有一个帮助我的问题。我试图做一个简单的事情与jQuery,它不做任何事情,这导致我相信jQuery甚至没有正确链接。但我做的正是我一直在做的。它应该改变这个div中的无序列表,将其背景颜色更改为橙​​色。它根本没有改变,但。我甚至尝试使用 console.log 来查看是否可以工作。它没有。有人可以检查这个吗?

There are a lot of posts on this site with the same title, but none of them helped with my problem. I'm trying to do a simple thing with jQuery, and it's not doing anything, which leads me to believe that jQuery isn't even properly linked. But I'm doing exactly what I've always done. It's supposed to change the unordered list in this div to change its background color to orange. It doesn't change at all, though. I even tried to use a console.log to see if even that would work. It didn't. Can someone check this out?


My code :

<script src="jquery-1.12.0.js">
    $(document).ready(function() {
        console.log("Why isn't this working?")
        $("#contentleft ul").css("background-color", "#FFA500");
    });
</script>

<div id="contentleft">
    <h3>My List Is Awesome</h3>
    <ul>
        <li><a href="http://www.fullsail.com">Full Sail</a></li>
        <li><a href="http://www.cnn.com">CNN</a></li>
        <li><a href="http://www.youtube.com">YouTube</a></li>
        <li>No link here.</li>
    </ul>
</div>


推荐答案

c>< script> 具有 src 的标记。

You can't put code inside <script> tag that has an src.

<script src="jquery-1.12.0.js"></script>

<script>
    $(document).ready(function() {
        console.log("Why isn't this working?")
        $("#contentleft ul").css("background-color", "#FFA500");
    });
</script>

这篇关于我的jQuery没有链接正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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