关于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,后一个设置会覆盖前面一个的设置。

原文地址:https://www.cnblogs.com/SusieHu/p/5401677.html