开发者

JQuery - remove cssObject after adding?

I do this:

var cssObject = {
                'background-color' : '#042c59',
                '-moz-box-shadow' : '0 0 22px #111',
                '-webkit-box-shadow' : '0 0 22px #111',
                'box-shadow' : '0 0 22px #111'
            }

                $('#mydiv').css(cssObject);
            开发者_JAVA技巧}

I can't seem to figure out how to remove that same cssObject from mydiv.


you are not adding a css object, you are adding a map that jquery interprets and sets the css values on the objects selected. If you want to toggle css style easily, I recommend addClass, removeClass, or toggleClass.

.selected{
background-color : #042c59,
-moz-box-shadow : 0 0 22px #111,
-webkit-box-shadow : 0 0 22px #111,
box-shadow : '0 0 22px #111
}

$('#mydiv').toggleClass("selected");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜