开发者

JQuery - remove cssObject after adding?

开发者 https://www.devze.com 2023-02-16 20:12 出处:网络
I do this: var cssObject = { \'background-color\' : \'#042c59\', \'-moz-box-shadow\' : \'0 0 22px #111\',

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

精彩评论

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