2013-03-08 16 views
2

我有一個DIV,裏面的div我有一個<a>,我想顯示鼠標<a>在上格如何在div上顯示<a>帶有實時功能?

<div style="position: relative"> 
    <img width="40" height="40" style="cursor:pointer" title="fwe" alt="image" src="../Images/DefaultPhotoMale.png" id="img513a06fa7f6d160310e09ac9"> 
    <a style="position: absolute;display:none; top: 1px; margin-left: 50px;">X</a> 
    </div> 

我這樣做,但我沒有得到正確的結果,我能夠看到未來的div另一方面,任何其他選項,請

$("#mycarousel").find("div").live({ 
     mouseenter: 
      function() { 
       $(this).find('a').show(); 
      }, 
     mouseleave: 
      function() { 
       $(this).find('a').hide(); 
      } 
    } 
    ); 
+3

.live()已貶值** **在jQuery 1.7 - http://api.jquery.com/live/ – adamb 2013-03-08 15:57:35

回答

2

對於jQuery 1.7,the live() method is deprecated的。改爲使用on()。它的工作原理很適合我這樣的:

Working demo

+0

是的,但我看到同樣的問題是什麼我面臨着,嘗試新的一頁,做鼠標和鼠標移動,你可以看到圖像的地方是不同的! – 2013-03-08 16:00:06

+0

有什麼問題! – 2013-03-08 16:01:37

+0

http://postimage.org/image/9uxfxe7nr/ – 2013-03-08 16:04:02