jQuery CSS plugin that returns computed style of element to pseudo clone that element?

后端 未结 9 1160
长情又很酷
长情又很酷 2020-11-22 15:27

I\'m looking for a way using jQuery to return an object of computed styles for the 1st matched element. I could then pass this object to another call of jQuery\'s css method

9条回答
  •  长发绾君心
    2020-11-22 15:41

    It's not jQuery but, in Firefox, Opera and Safari you can use window.getComputedStyle(element) to get the computed styles for an element and in IE<=8 you can use element.currentStyle. The returned objects are different in each case, and I'm not sure how well either work with elements and styles created using Javascript, but perhaps they'll be useful.

    In Safari you can do the following which is kind of neat:

    document.getElementById('b').style.cssText = window.getComputedStyle(document.getElementById('a')).cssText;
    

提交回复
热议问题