實(shí)在查不出來(lái)錯(cuò)在那里?(最后一個(gè)“取消設(shè)置”的按鈕,按了沒(méi)反應(yīng))
? </div>
? <form>
? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
??? <input type="button" onclick="color()" value="改變顏色" > ?
??? <input type="button" onclick="width1()" value="改變寬高" >
??? <input type="button" onclick="hide()" value="隱藏內(nèi)容" >
??? <input type="button" onclick="show()" value="顯示內(nèi)容" >
??? <input type="button" onclick="reset()" value="取消設(shè)置" >
? </form>
? <script type="text/javascript">
var change=document.getElementById("txt");
//定義"改變顏色"的函數(shù)
function color(){
change.style.color="red";
change.style.backgroundColor="yellow";
}
//定義"改變寬高"的函數(shù)
function width1(){
change.style.width="400px";
change.style.height="200px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function hide(){
change.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function show(){
change.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function reset(){
??? var massage=confirm("確認(rèn)重置嗎?");
??? if (massage==true){
??????? change.removeAttribute('style')
??? }
??? else{
?????? ?
??? }
}
最后一個(gè)“取消設(shè)置”的按鈕,按了沒(méi)反應(yīng),求教,謝謝!
2019-07-23
reset是javascript中的關(guān)鍵字不能用來(lái)做函數(shù)名,像你上面那樣改成reset1,就行了。