CSS () Get a simple package of the style current value and setting style

Get CSS style or set CSS style, compatible with IE, parameter one: element object, parameter two: attribute name, parameter three (optional): attribute value

function css() {

if (arguments.length == 2) {
//Get the style
if (getComputedStyle(arguments[0], false)) {
//Standard browser
var attr = arguments[1];
return getComputedStyle(arguments[0], false< span style="color: #000000;">)[attr];
} else {
//ie8-
var attr = arguments[1];
return arguments[0].currentStyle[attr];
}
}
else if (arguments.length == 3 ) {
//Set the style box.style.display ='none'< /span>
var attr = arguments[1];
arguments[
0].style[attr] = arguments[2];
}
}

Get CSS style or set CSS style, compatible with IE, parameter one: element object, parameter two: attribute name, parameter Number three (optional): attribute value

function  css() {

if (arguments.length == 2) {
//Get the style
if (getComputedStyle(arguments[0], false)) {
//Standard browser
var attr = arguments[1];
return getComputedStyle(arguments[0], false< span style="color: #000000;">)[attr];
} else {
//ie8-
var attr = arguments[1];
return arguments[0].currentStyle[attr];
}
}
else if (arguments.length == 3 ) {
//Set the style box.style.display ='none'< /span>
var attr = arguments[1];
arguments[
0].style[attr] = arguments[2];
}
}

Leave a Comment

Your email address will not be published.