Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过鼠标在文本上添加效果_Javascript_Jquery_Css - Fatal编程技术网

Javascript 如何通过鼠标在文本上添加效果

Javascript 如何通过鼠标在文本上添加效果,javascript,jquery,css,Javascript,Jquery,Css,我需要在鼠标悬停时为文本添加效果 我的js代码:- var j = jQuery.noConflict(); j(document).ready(function() { j('.related_box ul li').hover(function(event) { j(this).stop().animate({ right: "-5px" }, {duration: 'slow',easing: 'easeOutElastic'}); } , function(){ j(this).stop

我需要在鼠标悬停时为文本添加效果

我的js代码:-

var j = jQuery.noConflict();
j(document).ready(function() {
j('.related_box ul li').hover(function(event) {
j(this).stop().animate({ right: "-5px" }, {duration: 'slow',easing: 'easeOutElastic'});
}
,
function(){
j(this).stop().animate({ right: "-75px" }, {duration: 'slow',easing: 'easeOutElastic'});
});
});
Html代码:-

<div class="related_box">
<ul class="related_list_ul">
<li class="related_list"><h3><a href="#"></a><span>«</span> About us</h3></li>
<li class="related_list"><h3><a href="#"></a><span>«</span> Call us</h3></li>
<li class="related_list"><h3><a href="#"></a><span>«</span> Contact us</h3></li>
</ul>
</div>

  • «关于我们
  • «给我们打电话
  • «联系我们

如何通过鼠标在文本上添加效果。

您需要确保要设置动画的元素是
位置:相对
位置:绝对
,否则将
向右更改将不会有任何效果。

试试这个

j('.related_box > ul >  li > a').hover(function(event) {
您可以使用CSS来实现它

使用
mouseover()

示例:(此处测试)


问题是,代码运行得很好->您是否记得包含jQuery和jQuery UI?当然,您必须添加easings(jQuery UI)并设置初始位置。请添加更多说明。
li.related_list a:hover{ color: #xyz; }
var j = jQuery.noConflict();
j(document).ready(function() {

    j("li").mouseover(function(){
        j(this).animate({
        opacity: 0.25,
        left: "+=50",
        height: "toggle"
        }, 5000, function() {
        // Animation complete.
        }); // animate
   });
});