I have some trivial JavaScript to effect a style change:
sel = document.getElementById('my_id');
sel.className = sel.className.replace(/item-[1-9]-selected/,'item-1-selected');
return false;
This works fine with the latest versions of FF, Opera and IE, but fails on the latest versions of Chrome and Safari.
It affects two descendants, which happen to be siblings. The first sibling updates, but the second doesn’t. A child of the second element also has focus and contains the <a> tag that contains the above code in an onclick attribute.
In the Chrome “Developer Tools” window if I nudge (e.g. uncheck & check) any attribute of any element, the second sibling updates to the correct style.
Is there a workaround to easily and programmatically “nudge” WebKit into doing the right thing?
就我而言,“ display / offsetHeight” hack无效,至少在将其应用于动画元素时无效。
我有一个下拉菜单,正在页面内容上打开/关闭。菜单关闭后,工件才保留在页面内容上(仅在webkit浏览器中)。“ display / offsetHeight” hack唯一可行的方法是将其应用于身体,这似乎很讨厌。
但是,我确实找到了另一个解决方案:
这仍然很棘手(它使用CSS3属性来强制进行硬件渲染),但至少它只影响所涉及的元素,并且在PC和Mac上的Safari和chrome上都为我工作。