jQuery滑动切换图像交换不工作

jQuery滑动切换图像交换不工作,jquery,slidetoggle,Jquery,Slidetoggle,我的代码对于slideToggle函数非常有用,但是更多/更少的图像不会交换。在浏览器中本地预览时,图像仍为“更多”。上载版本的行为有所不同。在Safari中,它切换到空白图像,在FF中,它使用alt文本 我查看了档案,发现了类似的讨论,但由于我的代码除了这个小缺陷外工作正常,我希望不必使用不同的方法,因为我是jQuery新手。这一定很简单。我认为第二张图片的名字不正确很简单,但这不是问题所在 这里有一个链接 以下是脚本本身: <script src="../js-jquery/jquer

我的代码对于slideToggle函数非常有用,但是更多/更少的图像不会交换。在浏览器中本地预览时,图像仍为“更多”。上载版本的行为有所不同。在Safari中,它切换到空白图像,在FF中,它使用alt文本

我查看了档案,发现了类似的讨论,但由于我的代码除了这个小缺陷外工作正常,我希望不必使用不同的方法,因为我是jQuery新手。这一定很简单。我认为第二张图片的名字不正确很简单,但这不是问题所在

这里有一个链接

以下是脚本本身:

<script src="../js-jquery/jquery-1.7.2.min.js"></script>
<script>
$(document).ready(function(e) {
   $('.changeTextButton').click( function() {
       $('.moreText').slideToggle(500)
       if ( $(this).attr('src') == 'img/more-button.png' ) {
                $(this).attr('src','img/less-button.png')
       }
       else {
           $(this).attr('src','img/more-button.png')
       }
   })
});
</script>
以下是相关的html:

    <div class="content">
    <div class="firstText">
        <h1><img src="imgLeather/leatherSm.jpg" width="280" height="190" alt="leather" style="float:right;margin:5px 0 0 10px;">Leather Scents</h1>
        <p>After working for several years with different tanneries, Andrea Aromatics has developed what many in our industry acknowledge to be the best leather scents on the market today.  Due to newer tanning methods, some leathers produced today no longer have the desired “traditional” scent.  Another problem is that protective coatings used on some leathers actually impede the natural leather aroma from migrating through the surface.  These polymeric coatings make the leather smell more like plastic.</p>
        <p>Our leather scents have been used by tanneries to increase and enhance the aroma of their quality leathers, as well as by manufacturers of synthetic leather products to make their product simulate the real thing.  We offer leather scents in a variety of forms: liquid, powdered, and pelletized.</p>
      <!-- end .firstText--></div>
    <div class="moreText">
        <p>Natural leather hides can be deodorized and their aroma enhanced by several application methods:</p>
        <ol>
          <li>A water dispersible version of our leather scent can be incorporated into the final bath water to impart scent to the entire hide.</li>
          <li>A concentrated oil soluble version can be mixed into the finishing oil and applied along with it.</li>
          <li>A version can be diluted with alcohol and sprayed onto the “reverse” side.</li>
        </ol>
        <p>We do not recommend mixing the leather scents with proactive leather coatings since they may react and cause discoloration.  A slight yellowing may develop which would be objectionable in “white” or “pale blue” finished leather.  Darker colors and shades are usually not affected.</p>
        <p>We have been supplying our leather scents to the industry for over twenty years.  In that time our scents have been used in both natural and artificial leathers used by several major manufacturers both domestically and abroad.  They have also been used in scented advertising, consumer leather goods, furniture upholstery, toys and sporting goods.</p>
     </div><!-- end .moreText -->
       <img src="../imgGlobal/more-button.png" width="51" height="16" class="changeTextButton" alt="textButton">
      </div><!-- end .content -->

皮革香味
在不同的制革厂工作了几年后,Andrea Aromics开发出了我们行业中许多人公认的当今市场上最好的皮革香味。由于新的鞣制方法,今天生产的一些皮革不再具有所需的“传统”气味。另一个问题是,一些皮革上使用的保护涂层实际上阻止了天然皮革香气通过表面的迁移。这些聚合物涂层使皮革闻起来更像塑料

我们的皮革香味已被制革厂用于增加和增强其优质皮革的香气,也被合成皮革产品制造商用于使其产品模拟真实。我们提供多种形式的皮革香味:液体、粉末和颗粒

天然皮革可通过几种使用方法进行除臭,并增强其香气:

  • 我们的皮革香味的水分散版本可以被加入到最终的沐浴水中,为整个皮革提供香味
  • 浓缩油溶性版本可混合到涂饰油中,并与之一起使用
  • 一个版本可以用酒精稀释,喷在“反面”
  • 我们不建议将皮革气味与主动皮革涂层混合,因为它们可能会发生反应并导致变色。在“白色”或“淡蓝色”成品革中,可能会出现轻微的黄变,这是令人不快的。较深的颜色和阴影通常不受影响

    二十多年来,我们一直为该行业提供皮革香精。在此期间,我们的香味已被国内外几家主要制造商用于天然皮革和人造革。它们还被用于香水广告、皮革消费品、家具装潢、玩具和体育用品


    非常感谢任何能帮我找到罪犯的人

    。/imgGlobal/more-button.png

    是图像url,但您正在使用:img/more-button.png


    也许这是图像的错误路径。

    据我所知,您的代码是完美的

    您的问题是,正如您可能乐于听到的那样,您的服务器上不存在映像

    img/less-button.png 
    
    上传文件或将其更改为JS中的正确路径

    $(this).attr('src','WHEREAMI__img/less-button.png')
    

    谢谢你,杰米。嗯。当你在1.5小时内忽略了显而易见的事情时,拥有一双新的眼睛总是很好的!哈,1.5小时:我曾经花了2个小时才意识到我没有包含这个函数。init()谢谢你,弗兰克。我通过移动图像和更新html(而不是脚本)超越了自己(这很容易做到)。
    $(this).attr('src','WHEREAMI__img/less-button.png')