画像にホバーするとキャプション表示が出てくるようにjqueryで実装したのですがこれをすると画像をクリックするとサイトに飛ぶというa要素が効かなくなります。どうすればよいでしょうか。
HTML
1<section id="works"> 2 <h2 class="effect-fade"><img src="images/works.png"></h2> 3 <ul class="flexcontainer"> 4 <li class="flexitem effect-fade"> 5 <a href="http://サイトアドレス" target="_blank" ><img src="images/thum1.png" width="" height="" "></a></li> 6 <li class="flexitem effect-fade"><a href="http://サイトアドレス" target="_blank" ><img src="images/thum2.png" width="" height="" alt=""></a></li> 7 </ul>
css
1#works ul li { 2 position: relative; 3 list-style: none; 4} 5 6 7.flexcontainer div { 8 position: absolute; 9 display: none; 10 width: 100%; 11 height: 100%; 12 padding: 20px; 13 background: rgba(17, 179, 179, .7); 14 top:0; 15 left:0; 16 box-sizing: border-box; 17} 18 19.flexcontainer p { 20 position: relative; 21 top: 10px; 22} 23
jquery
1$(".flexcontainer li").hover( 2 function () { 3 $(this).append("<div><p>" + $(this).children("a").children("img").attr("alt") + "</p></div>"); 4 $(this).children("div").stop().fadeIn(300); 5 6 //キャプションのテキスト位置:10pxから0pxへ移動 7 $(this).children("div").children("p").stop(). 8 animate({ "top": 0 }, 300); 9 }, 10 function () { 11 $(this).children("div").stop().fadeOut(300); 12 13 $(this).children("div").children("p").stop(). 14 animate({ "top": "10px" }, 300, function () { 15 $(this).parent("div").remove(); 16 }); //アニメーション事後処理 17 } //マウスアウト時の処理 18 );
回答1件
あなたの回答
tips
プレビュー