removeAttr(“style”)和attr(“style”,“”)不起作用

时间:2012-11-28 01:20:19

标签: jquery attr

http://synergine.net/rain.php

您好。我正在尝试清除.ripple divs中所有元素的style属性,但没有成功:

function contact(level){
focus_ripple = Math.floor(Math.random() * 100) + 1;
$("#"+level+" .ripple"+focus_ripple+" p").css("opacity",1);
$("#"+level+" .ripple"+focus_ripple+" .fourth").animate({
    height: "324px",
    width: "324px",
    top: "-162px",
    left: "-162px",
    "border-radius": "162px"
},{duration: 1000, queue: false});
$("#"+level+" .ripple"+focus_ripple+" .third").animate({
    height: "108px",
    width: "108px",
    top: "-54px",
    left: "-54px",
    "border-radius": "54px"
},{duration: 1000, queue: false});
$("#"+level+" .ripple"+focus_ripple+" .second").animate({
    height: "32px",
    width: "32px",
    top: "-18px",
    left: "-18px",
    "border-radius": "18px"
},{duration: 1000, queue: false});
$("#"+level+" .ripple"+focus_ripple+" .first").animate({
    height: "10px",
    width: "10px",
    top: "-6px",
    left: "-6px",
    "border-radius": "6px"
},{duration: 1000, queue: false});
$("#"+level+" .ripple"+focus_ripple+" p").animate({
    opacity: 0
},{duration: 1550, queue: false});
setTimeout(function() {
    $("#"+level+" .ripple"+focus_ripple+" p").removeAttr("style");
},1575);
counter++;

}

非常感谢任何帮助。感谢。

1 个答案:

答案 0 :(得分:0)

removeAttr()适用于1.7.2:

$("div").click(function(){
    $(this).removeAttr("style");
})​

请参阅小提琴:http://jsfiddle.net/adrianonantua/p5Dcs/

你必须确保选择器真正带来结果。