首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

怎么改变input的style属性

2012-02-25 
如何改变input的style属性?scriptlanguage javascript functionchange(){。。。。。}/scriptinputid

如何改变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() ">

热点排行