Home >Web Front-end >JS Tutorial >Get styles in inline and links (js code)_javascript tips

Get styles in inline and links (js code)_javascript tips

WBOY
WBOYOriginal
2016-05-16 17:37:181158browse
Copy code The code is as follows:

var head = document.getElementById( "box" );
// alert( head.style.background )
// alert( head.style.cssFloat || head.style.styleFloat ) // Getting float is different
// head.style.fontSize = "30px"
head.style.color = "#f00";
// (typeof head.style.cssFloat != "undefined" ) ? head.style.cssFloat = "right" : head.style.styleFloat = " right" cross-browser setting float
// var style = ( window.getComputedStyle ? window.getComputedStyle( head,null ) : null ) || head.currentStyle; cross-browser to obtain the calculated style
// alert( style.fontSize )
// This way you can get inline and link
// Because the calculated style will reside in the browser's calculated style, you can get
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn