关于style设置方法,obj.setAttribute("style"."")和obj.style.stylename

1、使用obj.setAttribute("style"."")方法;

obj.setAttribute("style","-webkit-clip-path: polygon(0% 0%, 66% 0, 33% 100%, 0% 100%);float:none;");
obj.setAttribute("style","position:absolute;background-image:url(1.jpg);");

如果在一个js代码中,同时对一个obj对象使用setAttribute方法设置style,后一个设置会覆盖前面一个的设置。

posted @ 2016-04-17 18:04  栀子花的味道  阅读(3160)  评论(0编辑  收藏  举报