jquery - 如果链接仅显示源代码并将其连接到我的 html,如何下载 Jquery

标签 jquery css html

我是第一次使用 jQuery,但无法下载它。 我是新来的。如果我没有正确完成它,我深表歉意;欢迎任何建设性的批评。 我对编码很陌生。我现在已经上了 3 个季度的大学,并且已经开始学习 C#、Ruby、html、SQL、JS 和 PS。我知道数据类型、函数、变量和循环……但我对语法知之甚少,我真的很挣扎。 我需要新手级别的帮助,希望通过清晰简单的步骤让我的 jQuery 从下载到工作。 我觉得有点傻,但我已经这样做太久了,需要帮助。我相信对于熟悉它的人来说,这相当简单。有人请帮助!!!!我花了太多时间尝试没有结果....

为了做到这一点,我知道我需要粘贴一个 Jquery 库文件“下载未压缩的开发 jQuery 1.11.3” 和...“下载未压缩的开发 jQuery Migrate 1.2.1” 来自 jQuery 官方网站。

我试图下载它,但我得到的只是源文件。我观看了 utube vids 来学习,但没有找到太多,我找到的是针对特定教程目标的,我无法吸收它。

我明白,为了在我的 html 中获取我的 jQuery 库,我需要这个:

不确定它是在 html 的头部还是主体中……我想我把它放在了正确的位置? 我被告知必须在我的 CDN 前面添加 http:。

我正在努力做到这一点:

我的页面应该如何工作。 页面加载并关闭所有标题。当用户单击带有加号的标题时,将显示下面的文本并且加号变为减号。如果用户单击带有减号的标题,文本将隐藏并且符号变为加号。

我有一个 html 页面:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FAQs</title>
    <link rel="shortcut icon" href="images/favicon.ico">
    <link rel="stylesheet" href="index.css">
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="faqs.js"></script>     

</head>

<body>
    <section id="faqs">
        <h1>jQuery FAQs</h1>
        <h2><a href="#" id="first_link">What is jQuery?</a></h2>
        <div>
            <p>jQuery is a library of the JavaScript functions that you're most likely 
               to need as you develop web sites.
            </p>
        </div>
        <h2><a href="#">Why is jQuery becoming so popular?</a></h2>
        <div>
            <p>Three reasons:</p>
            <ul>
                <li>It's free.</li>
                <li>It lets you get more done in less time.</li>
                <li>All of its functions are cross-browser compatible.</li>
            </ul>
        </div>
        <h2><a href="#">Which is harder to learn: jQuery or JavaScript?</a></h2>
        <div>
            <p>For most functions, jQuery is significantly easier to learn 
                and use than JavaScript. But remember that jQuery is JavaScript.
            </p>
        </div>
    </section>
</body>
</html>

我有一个 .css 页面:

/* type selectors */
article, aside, figure, figcaption, footer, header, nav, section {
    display: block;
}
* {
    margin: 0;
    padding: 0;
}
body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 87.5%;
    width: 650px;
    margin: 0 auto;
    border: 3px solid blue;
}
section {
    padding: 15px 25px;
}
h1 { 
    font-size: 150%;
}
h2 {
    font-size: 120%;
    padding: .25em 0 .25em 25px;
    cursor: pointer;
    background: url(images/plus.png) no-repeat left center;
}
h2.minus {
    background: url(images/minus.png) no-repeat left center;
}
a {
    color: black;
    text-decoration: none;
}
h2:hover {background-color: #ccccff;}
a:focus, a:hover {
    color: blue;
}
div {
    display: none;
}
div.open {
    display: block;
}
ul {
    padding-left: 45px;
}
li {
    padding-bottom: .25em;
}
p {
    padding-bottom: .25em;
    padding-left: 25px;
}

and two .png images that are a and a minus plus signs.

最佳答案

您正确地包含了 jquery,如您的 <head>部分你有以下内容:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

这里你包括 jquery 的 1.9.1 版本,但是在这个答案的时候有它的最后两个版本,1.11.3 和 2.1.4,它们是一样的,只是在支持 internet explorer 版本 8 和下面的浏览器,如果你需要支持这些浏览器那么使用 1.x 版本,如果不使用这里提到的 2.x 版本 http://jquery.com/download/#jquery-2-x

jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8. All the notes in the jQuery 1.9 Upgrade Guide apply here as well. Since IE 8 is still relatively common, we recommend using the 1.x version unless you are certain no IE 6/7/8 users are visiting the site.

所以下载 1.11 版本就安全了。

关于在您的网页中包含 jquery 的位置,它可以在 head</body>之前的部分或页底但请记住,您要使用 jquery 进行的所有编码都需要在页面中包含 jquery 之后完成或包含。

如果你打算在头部加载它,确保在 $(document).ready(function{ /*your code here */}); 中编写你的 jquery 函数。以便它等到 HTML DOM 准备就绪,但如果您要在关闭 body 之前包含它在页面底部,则无需将其包装在 document.ready() 中功能。

请记住,始终包括缩小的生产 .min.js文件,因为它经过压缩且大小更小 - 97KB 与未压缩文件的 277KB 相比 - 在大多数情况下你并不真正需要开发版本

关于jquery - 如果链接仅显示源代码并将其连接到我的 html,如何下载 Jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33512702/

相关文章:

javascript - 对于多个函数,更简单的编写 if val = 的方法

javascript - 元素不会附加到容器

jquery - 使用 jQuery 在单独的 DIV 中包装任意内容(H2、H3、P 等)

java - 尝试在Java中的所有页面中维护 session

javascript - 隐藏 <div> onload 并显示点击事件无法正常工作

javascript - 获取 ul 的所有值到变量中

android - 如何在数据角色 ="footer"(用于动态加载数据的页脚)上应用鼠标和触摸滑动?

html - CSS嵌套组合器

javascript - 单击添加几行并双击删除添加的行

JavaScript 无法通过 SharedWorker() 构造函数