為什么執(zhí)行不出來
? <input type="button" value="改變顏色" click="a()"> ?
? ? <input type="button" value="改變寬高" click="b()">
? ? <input type="button" value="隱藏內(nèi)容" click="c()">
? ? <input type="button" value="顯示內(nèi)容" click="d()">
? ? <input type="button" value="取消設(shè)置" click="e()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
function a(){
? ? var mychar=document.getElementById("txt");
? ? mychar.style.color="red";
? ? mychar.style.backgroundColor="#ccc";
}
//定義"改變寬高"的函數(shù)
function b(){
? ? var mychar=document.getElementById("txt");
? ? mychar.style.width="200px";
? ? mychar.style.height="50px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function c(){
? ? var mychar=document.getElementById("txt");
? ? mychar.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function d(){
? ? var mychar=document.getElementById("txt");
? ? mychar.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function e(){
? ? var mychar=confirm("是否 取消 設(shè)置 ?");
? ? var txt=document.getElementById("txt");
? ? if(mychar){
? ? ? ?txt.removeAttribute('style');
? ? }
}
2016-11-21
觸發(fā)事件是onclick不是click~
2016-11-17
知道了,不用回答,謝謝~