【发布时间】:2016-11-08 22:28:39
【问题描述】:
我使用,(请不要介意选择器,我知道它应该更改但仍然找到)。
let leftArrow = <HTMLElement> document
.querySelector('div[style="position: absolute; left: 6px; transform: skewX(22.6deg);' +
' transform-origin: 0px 0px 0px; height: 24px; width: 10px;' +
' box-shadow: rgba(0, 0, 0, 0.6) 0px 1px 6px; background-color: rgb(255, 255, 255);"]');
然后我使用:
let myStyle = leftArrow.style; //this gets me a CSSStyleDeclaration object
console.log(myStyle); // those are equal objects
console.log(leftArrow.style); // those are equal objects
但是当我这样做时:
leftArrow.style = myStyle; //this should change nothing ?!
我的元素消失了?!
我的目标是使用一个类,然后这样做:
leftArrow.style = this.getStyleFromClass(selector_to_find_class_name);
但简单之后:
leftArrow.style = myStyle;
我从上面的元素变成:
<div></div>
这使得它基本上不可见。为什么?
【问题讨论】:
-
控制台有错误提示吗?
-
您是否要恢复应用的样式?您将需要以不同的方式来解决这个问题。
标签: javascript css dom typescript angular