将鼠标悬停在内部链接上时,jQuery会淡出段落

将鼠标悬停在内部链接上时,jQuery会淡出段落,jquery,jquery-animate,Jquery,Jquery Animate,我有以下代码: <p> Non in porttitor porta. Amet ridiculus? Adipiscing cum scelerisque aliquam, tortor ac mauris platea? Vel in amet non nec facilisis, phasellus.<br /> Sagittis diam auctor ultricies in habitasse integer vel duis sociis rh


我有以下代码:

<p>
   Non in porttitor porta. Amet ridiculus? Adipiscing cum scelerisque aliquam, tortor ac mauris platea? Vel in amet non nec facilisis, phasellus.<br /> 
   Sagittis diam auctor ultricies in habitasse integer vel duis sociis rhoncus
   <a href="something.html">porttitor</a>?
</p>
但是它不起作用!!请帮助大家……

我知道这个技术是完全错误的。。。但是如果可以使其

不透明度会影响受影响元素的所有子元素

您需要设置
color
属性(alpha通道)不透明度的动画

要做到这一点,您需要一个支持rgba的浏览器(不是IE)和一个插件

允许动画使用
颜色
背景色
,但尚不适用于rgba版本

因此,您可以在和使用插件


例如,

这应该是跨浏览器的,只需将段落中除段落内部的a元素外的所有文本用span换行,然后淡出span元素即可

我使用可见性来保持链接在段落的位置,否则它会跳到段落的开头,因为跨距是隐藏的,显示:无

你可以在网上查看

$(“PA”).hover(函数(){
var p=$(this.parent();
p、 内容(“:非(a)”)。换行(“”);
p、 查找(“范围”).fadeOut(函数(){
$(this.removeAttr(“style”).css(“可见性”、“隐藏”);
});
},函数(){
$(this).parent().find(“span”).removeAttr(“style”).hide().fadeIn();
}
);

这里的问题是,如果
p
淡出,那么它的所有内容都会淡出,
a
。是的@dave,我假设是这样。如果可能的话,你能告诉我一种全新的技术吗。提前一吨…一吨。。。!!thnq thnq和thnq。。。你让我开心!!:)但你能告诉我它在哪些网络浏览器中真正起作用吗??plz…@Devashish,所有(FF、Chrome、Safari、Opera),但IE(最多IE8)。我没有安装IE9,所以说不出来。(据认为,它应该支持它)
$(document).ready(function() {
    $('p a').hover(function() {
        $(this).parent('p').not('a').animate({
             opacity: "0.5"
        }, 3000);
        },
        function() {
        $(this).parent('p').not('a').animate({
             opacity: "1"
        }, 3000);
     });
 });
$(document).ready(function() {
    $('p a').hover(function() {
        $(this).parent('p').animate({
             color: 'rgba(0,0,0,0.5)'
        }, 500);
        },
        function() {
        $(this).parent('p').animate({
             color: 'rgba(0,0,0,1)'
        }, 500);
     });
 });
$("p a").hover(function(){
       var p =  $(this).parent();
       p.contents(":not(a)").wrap("<span />");

       p.find("span").fadeOut(function(){
            $(this).removeAttr("style").css("visibility","hidden");
       });
   },function(){   
       $(this).parent().find("span").removeAttr("style").hide().fadeIn();
   }
);