/ / div内の各imgにhrefを入れる方法(slideshow Jquery) - jquery、slideshow、href

div内の各imgにhrefを入れる方法(スライドショーJquery) - jquery、slideshow、href

私はJquery Slideshowを http://jonraasch.com/blog/a-simple-jquery-slideshow すべてがうまくいきます。私はdiv内の各画像のハイパーリンクを入れたいと思いますが、その中に背景を入れたら最初の画像だけが表示され、他の画像は表示されません。

サンプルはリンクの内側にあります:http://jonraasch.com/blog/a-simple-jquery-slideshow

注:私は、スライドショーのすべての画像に異なるリンクが必要です。

回答:

回答№1は0

これを試して :-

----- jsの変更----

    var $active = $("#slideshow a.active");

if ( $active.length == 0 ) $active = $("#slideshow a:last");

// use this to pull the images in the order they appear in the markup
var $next =  $active.next().length ? $active.next()
: $("#slideshow a:first");

------変更はcss -------

/*** set the width and height to match your images **/

#slideshow {
position:relative;
height:350px;
}

#slideshow a {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}

#slideshow a.active {
z-index:10;
opacity:1.0;
}

#slideshow a.last-active {
z-index:9;
}

</style>

--- htmlの変更---

<div id="slideshow">
<a href="#"> <img src="/images/image1.jpg" alt="Slideshow Image 1" class="active" /></a>
<a href="#"> <img src="/images/image2.jpg" alt="Slideshow Image 2" /></a>
<a href="#"> <img src="/images/image3.jpg" alt="Slideshow Image 3" /></a>
<a href="#"> <img src="/images/image4.jpg" alt="Slideshow Image 4" /></a>
</div>

回答№2の場合は3

あなたは 関数。

var images = $("#slideshow").children("img");
$.each(images,function(){
images.wrap("<a href="#"></a>");
});

注:Havenはこのコードを自分で試しました。