2014-09-22 87 views
1

我們是ASM程序員,無html/css/js網頁體驗。我想要一系列的線,也許30,當一個線懸停時,隱藏的文本出現,當懸停移動時隱藏。我們從網站上的jQuery答案中選擇了代碼,但無法使其工作。謝謝。懸停並顯示代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html><head> 
    <script src="jquery-1.11.1.js"></script> 
    <meta charset="utf-8"><title>puff1</title> 

    </head> 
    <body> 
     <a href="#Dud" class="mark">Hover here</a> 
     <div class="icontent"> 
      <p> Some nice Queen's english here ..." </p> 
     </div> 

$(".mark").on({ 
    mouseover: function() { 
    $(".icontent").stop().show(1000); 
    }, 
    mouseout: function() { 
     $(".icontent").stop().hide(1000); 
     } 
    }) 
</body> 
</html> 

回答

2

裹在<script>標籤代碼:

<script> 
    $(".mark").on({ 
     mouseover: function() { 
      $(".icontent").stop().show(1000); 
     }, 
     mouseout: function() { 
      $(".icontent").stop().hide(1000); 
     } 
    }) 
</script> 
0

也許你想要的東西,像this

<script> 
    $(function(){ 
     $(".mark").on({ 
      mouseenter: function() { 
       $(this).next(".icontent").stop().show(1000) 
      }, 
      mouseleave: function() { 
       $(this).next(".icontent").stop().hide(1000); 
      } 
     }); 
    }); 
</script> 

因爲你說:

我想有一個系列,也許30, 當一個人在一條線上盤旋時,隱藏文本出現,並在 時隱藏起來。

所以,顯示或使用$(".icontent")將導致與類icontent所有元件在同一時間顯示/隱藏隱藏。