Javascript 获取更新脚本并添加样式表

Javascript 获取更新脚本并添加样式表,javascript,Javascript,我试图用这个脚本来更新内容,但我的引用根本没有出现。此外,我还需要在引号中添加一些CCS。我需要帮助解决代码故障。这里有一个到原始问题的链接,我以实现它的方式附加代码 update-content.html: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script

我试图用这个脚本来更新内容,但我的引用根本没有出现。此外,我还需要在引号中添加一些CCS。我需要帮助解决代码故障。这里有一个到原始问题的链接,我以实现它的方式附加代码

update-content.html:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="quotes.js">
</head>
<body>
<div id="quotes-wrapper" class="quote-29">
  <div class="quote">Testimonial Week 29</div>
  <div class="author">Author</div>
</div>
<div id="quotes-wrapper" class="quote-30">
    <div class="quote">Testimonial Week 30</div>
    <div class="author">Author</div>
</div>
<div id="quotes-wrapper" class="quote-31">
    <div class="quote">Testimonial Week 31</div>
    <div class="author">Author</div>
</div>
</body>
这是你的错误

<script type="text/javascript" src="quotes.js">

应该是

<script type="text/javascript" src="quotes.js"></script>


此外,您还缺少jquery库,该库应添加到脚本之前。

我遇到了两个问题:

  • 您已经为所有三个
    div
    元素指定了与
    id=“quotes wrapper”
    -id相同的id,因此当您将其用作选择器时,我希望jQuery只找到第一个。考虑到HTML的其余部分,您可能希望基于类而不是id为jQuery提供一个选择器

  • 在此代码中传递给
    load()
    函数的URL:

  • $('#quotes wrapper').load('update-content.html div.quote-'+weekno)

    似乎不对。在
    .html
    后面有一个空格,我希望在那里有一个
    和一个或多个参数

    因此,考虑到以上两点,我希望更像:

    $('div.quote-'+weekno).load('update-content.html?someParam='+weekno)

    $('#someuniqueid').load('update-content.html?someParam='+weekno)


    您还需要一个结束标签。

    谢谢,伙计们!我将仔细研究这些建议,然后回复帖子。
    <script type="text/javascript" src="quotes.js"></script>