日期:2014-05-16 浏览次数:20805 次
var d= document.getElementById("container");
d.style.height="7px";
d.style.weight="17px";
<input type="text" id="inp1" style="height:9px;color:red"/> <input type="button" onclick="getStyle()"/>
document.getElementById('inp1').style.cssText; //获取input标签的样式"width: 220px; height: 20px;" //设置标签样式
function getStyle(){
var addCss=document.getElementById('inp1').value;
var strCss=document.getElementById('inp1').style.cssText;
alert(strCss+addCss);
}
function setStyle(el, strCss){
var sty = el.style;
sty.cssText = sty.cssText + strCss;
}