2013-05-27 138 views
-5

my fiddle使用JavaScript顯示和隱藏div?

 $szPostContent = $post->post_content; 
     $szSearchPattern = '#(<img.*?>)#'; 
     $a=''; 
     $aPics=''; 
     preg_match_all($szSearchPattern, $szPostContent, $aPics); 
     $iNumberOfPics = count($aPics); 
     echo "<br />Number of pics on each post...............".$iNumberOfPics; 
     array_push($postimg, $iNumberOfPics); 

$ iNumberofPics顯示了從單一圖像後... 看看演示..u會發現,在箭頭imgthe滑塊dissapears.while的鼠​​標懸停我想不間斷的顯示,主要DIV,直到用戶仍然在那裏...

+0

HTTP ://jsfiddle.net/AjAw9/5/ – Spokey

+0

@Spokey - 謝謝你的回覆,但我想要顯示的imagelider div和兩個箭頭類和mousel的imagelider div我想隱藏imagelider div –

回答

1
<div class='container' style='height:150px; width:225px;'> 
    <div class="imageslider" id="imageslider" style="border: 1px solid #000000; height:150px; width:225px;display:none"> 
     <img class="arrow left" style="border: 1px solid #000000; height:25px; width:25px; float:left; margin-top:50px;" /> 
     <div class="images"></div> 
     <img class="arrow right" style="border: 1px solid #000000; height:25px; width:25px; float:right; margin-top:50px;" /> 
    </div> 

和文字

$(".container").hover(function() { 
    $(this).find('.imageslider').show(); 
}, function() { 
    $(this).find('.imageslider').hide(); 
}); 

FIDDLE

.container是那裏爲了一個佔位符你能夠鼠標過來,出

1

我不知道如果我的問題得到了解決,所以我希望其中一種方法可以幫助您: 在您的代碼中使用onmouseout而不是onmouseover。您可以:

  • 在mouseover和mouseout上使用$(...)。show()和$(...)。hide()。
  • 看看$(...)。toggle(),這將帶走一些工作。