button 全沒(méi)反應(yīng) 蜜汁 大佬來(lái)看看
?<form>
? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
? ? <input type="button" value="改變顏色" onclick="setColor()" />??
? ? <input type="button" value="改變寬高" onclick="setHeight()" />
? ? <input type="button" value="隱藏內(nèi)容" onclick="dis1()"/>
? ? <input type="button" value="顯示內(nèi)容" onclick="dis2()"/>
? ? <input type="button" value="取消設(shè)置" onclick="button()"/>
? </form>
? <script type="text/javascript">
? var text=document.getElementById('text');
//定義"改變顏色"的函數(shù)
?function setColor(){
? ??
? ? text.style.color="blue";
}
//定義"改變寬高"的函數(shù)
?function setHeight(){
? ? ? ? ? ? ?
? ? ? ? ? ? text.style.height="400";
?}
//定義"隱藏內(nèi)容"的函數(shù)
?function dis1(){
? ??
? ? text.style.display="none";
? ??
?}
//定義"顯示內(nèi)容"的函數(shù)
function dis2(){
? ? text.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
?function button(){
var setting=confirm("是否取消設(shè)置");
if(setting){
? text.removeAttribute("style");
}
}
? </script>
2020-06-29
?var text=document.getElementById('text'); // text改為txt 。