日期:2014-05-16  浏览次数:20644 次

如何改变input的style属性?
<script   language= "javascript ">
function   change(){
。。。。。
}
</script>
<input   id= "aa "   type= "text "   value= "microsoft "     />
<input   id= "bb "   type= "button "   value= "change "   onClick= "change() ">
我想通过点击按钮,修改aa的style为style= "background-color:#CCCCCC "。
能不能不用form定义?


------解决方案--------------------
aa.style.backgroundColor = "#CCCCCC "
------解决方案--------------------
<script language= "javascript ">
function change(){
var aa=document.getElementById( 'aa ');
aa.style.backgroundColor = "#CCCCCC "
}
</script>
<input id= "aa " type= "text " value= "microsoft " />
<input id= "bb " type= "button " value= "change " onClick= "change() ">