2012-06-26 15 views
0

我已經在我的php網站中實現了jquery滾動文本。見我的代碼jquery scoll文本需要仍然在鼠標上方

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 

     $('.scrollingtext').bind('marquee', function() { 
      var ob = $(this); 
      var tw = ob.width(); 
      var ww = ob.parent().width(); 
      ob.css({ left: -tw }); 
      ob.animate({ left: ww }, 20000, 'linear', function() { 
       ob.trigger('marquee'); 
      }); 
     }).trigger('marquee'); 

    }); 
    </script> 

在主體部分

<div class="jp-title"> 

    <ul> 
    <li class="scrollingtext" > 

    <a href="index" >welcome </span> 

    </li> 
    </ul> 

</div> 

我需要讓這個滾動文本BAS還是當鼠標懸停上的文字。但我不知道如何?

請回復

回答

0

你必須綁定一個mouseenterhover事件的scrollingtext元素停止動畫,像這樣:我猜鼠標離開後要重新啓動

$(".scrollingtext").bind("mouseenter", function() { 
    $(this).stop(); 
}); 

滾動。試試這個:

$(".scrollingtext").bind("hover", function() { 
    // equivalent to mouseenter. stop() stops all animation 
    $(this).stop(); 
}, function() { 
    // equivalent to mouseleave. this triggers your already existing 'marquee' event 
    $(this).trigger("marquee"); 
});