為什么一點(diǎn)反應(yīng)都沒有
?<script type="text/javascript">
//定義"改變顏色"的函數(shù)
function color(){
? ? var col=document.geElementById("txt");
? ? col.style.backgroundColor="blue";
}
//定義"改變寬高"的函數(shù)
function high(){
? ? var h=document.geElementById("txt");
? ? h.style.width="500px";
? ? h.style,height="500px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function none(){
? ? var no=document.geElementById("txt");
? ? no.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function block(){
? ? var no=document.geElementById("txt");
? ? no.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function qu(){
? ? ?txt.removeAttribute("style");
}
2018-08-06
因?yàn)槟銢]在按鈕里面添加響應(yīng)onclick
2018-08-08
可以將獲取txt的元素id對(duì)象抽取到方法外面,這樣就不用重復(fù)le
2018-08-06
<form>
? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
? ? <input type="button" value="改變顏色" onClick="color()">??
? ? <input type="button" value="改變寬高" onClick="high()">
? ? <input type="button" value="隱藏內(nèi)容" onClick="none()">
? ? <input type="button" value="顯示內(nèi)容" onClick="block()">
? ? <input type="button" value="取消設(shè)置" onClick="quxiao()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
function color(){
? ? var col=document.geElementById("txt");
? ? col.style.backgroundColor="blue";
}
//定義"改變寬高"的函數(shù)
function high(){
? ?// var h=document.geElementById("txt");
? ?text.style.width="500px";
? ? h.style,height="500px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function none(){
? ? var no=document.geElementById("txt");
? ? no.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function block(){
? ? var no=document.geElementById("txt");
? ? no.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function qu(){
? ? ?txt.removeAttribute("style");
}
? </script>
2018-08-06
在<form>標(biāo)簽里的button少一部分代碼,可以對(duì)比之前課程的按鈕,寫一個(gè)onClick= "函數(shù)名()"就好了