Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在javascript滑块中向图像添加单个链接_Javascript_Jquery_Html_Css - Fatal编程技术网

无法在javascript滑块中向图像添加单个链接

无法在javascript滑块中向图像添加单个链接,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个客户端站点的javascrpit滑块,我不知道如何链接滑块中的各个图像。滑块功能齐全,除了链接问题外,还非常有效 我发现,如果我从下面删除项目,我可以链接图像,并让它们作为正常的链接,但我失去了javaslider功能。我什么都试过了 我的目标是将每个图像链接到网站上各自的页面。共有4张图片。我对这东西很陌生,所以任何帮助都会很棒 <script> $(document).ready(function(){ $('.gallery')._TMS({

我有一个客户端站点的javascrpit滑块,我不知道如何链接滑块中的各个图像。滑块功能齐全,除了链接问题外,还非常有效

我发现,如果我从下面删除项目,我可以链接图像,并让它们作为正常的链接,但我失去了javaslider功能。我什么都试过了

我的目标是将每个图像链接到网站上各自的页面。共有4张图片。我对这东西很陌生,所以任何帮助都会很棒

<script>
    $(document).ready(function(){
      $('.gallery')._TMS({
      show:0,
      pauseOnHover:true,
      prevBu:'.prev',
      nextBu:'.next',
      playBu:'.play',
      duration:700,
      preset:'fade',
      pagination:$('.img-pags').uCarousel({show:4,shift:0}),
      pagNums:false,
      slideshow:7000,
      numStatus:true,
      banners:false,
      waitBannerAnimation:false,
      progressBar:false 



      })        
 })
网站

    <div class="container_12">
      <div class="grid_12">
        <div id="slide">                
            <div class="gallery">
            <ul class="items">

                    <li><a href="about.html"><img src="images/gallery-big-1.jpg" alt="">     </a></li>

                    <li><img src="images/gallery-big-5.jpg" alt=""></li>

                    <li><img src="images/gallery-big-2.jpg" alt=""></li>

                    <li><img src="images/gallery-big-6.jpg" alt=""></li>
               </ul>

            </div>
            <a href="#" class="prev"></a><a href="#" class="next"></a>
        </div>      
      </div>



#slide {  width:940px; height:415px; position:relative; overflow:hidden; z-index:2; }

.gallery {
width:940px;
position:relative;
z-index:2
}
.items {display:none;}
.pag { position:relative;}
.img-pags {position:static; left:0px; z-index:1; display:block;}
.img-pags ul {margin:0}
.img-pags li { width:200px; height:170px; margin-right:20px; display:block;     overflow:hidden;  }
.img-pags li a {position:relative;display:block;border:#f4f4f4 5px solid; }
.img-pags li a img {}
.img-pags li a span{ display:block; background:#fff;}
.img-pags li.active a,.img-pags li a:hover{border:#CCC 5px solid;}
.img-pags li.active a img,.img-pags li a:hover img{}
.prev {background:url(../images/prev-1.gif) 0 0 no-repeat; bottom:1px; left:1px;      display:block; position:absolute; width:44px;height:44px; z-index:9999;}
.next{background:url(../images/next-1.gif) 0 0 no-repeat; bottom:1px; right:1px; display:block; position:absolute; width:44px;height:44px; z-index:9999;}
.prev:hover, .next:hover {background-position: 0 bottom;}

在中使用jQuery包装库图像

HTML

jQuery

提示:把这个放在HTML的前面

$(function() {

  $('.gallery ul li img').each(function() {

    var imgHref = $(this).attr('data-link');

    $(this).wrap('<a href="' + imgHref + '"</a>');

  });

});

很明显,你还没有试过所有的方法,否则它会起作用的你用的是什么滑块?来把小提琴怎么样?欢迎来到SO!JSFIDLE通常受到我们社区的欢迎。它帮助我们更好地理解您的代码。Lol。你说得对,到目前为止,我感觉我已经尝试了我所知道的一切,而这是非常少的。我使用的是一个模板,其中提供了slider/uCarousel.js。我得到了模板,并被要求改变一些事情,以使小企业主高兴。我非常了解html和css,但对javascript.span和isherwood却一无所知,谢谢您提供的jsfiddle.net链接。我会调查一下,看看结果如何。我真的很感谢你的帮助。这是来自Fiddle的链接。
$(function() {

  $('.gallery ul li img').each(function() {

    var imgHref = $(this).attr('data-link');

    $(this).wrap('<a href="' + imgHref + '"</a>');

  });

});