沒問題吧各位大神?
?<form>
? <!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
? ? <input type="button" value="改變顏色" onclick="a()">??
? ? <input type="button" value="改變寬高" onclick="b()">
? ? <input type="button" value="隱藏內容" onclick="c()">
? ? <input type="button" value="顯示內容" onclick="d()">
? ? <input type="button" value="取消設置" onclick="e()">
? </form>
? <script type="text/javascript">
? ?var obj = document.getElementById("txt");
??
//定義"改變顏色"的函數
function a(){
? ? obj.style.color="red";
}
//定義"改變寬高"的函數
function b(){
? ? obj.style.width="200px";
? ? obj.style.height="300px";
}
//定義"隱藏內容"的函數
function c(){
? ? obj.style.display="none";
}
//定義"顯示內容"的函數
function d(){
? ? obj.style.display="block";
}
//定義"取消設置"的函數
function e(){
? ? var i = confirm("是否取消?");
? ? if(i==true){
? ? ? ? obj.removeAttribute("style");
? ? }
}
? </script>
2019-01-03
你可以把代碼復制到自己的工具上查看