<form>
??<!--當點擊相應按鈕,執(zhí)行相應操作,為按鈕添加相應事件-->
????<input?type="button"?value="改變顏色"?onclick="changc()">??
????<input?type="button"?value="改變寬高"?onclick="changew()">
????<input?type="button"?value="隱藏內容"?onclick="hide()">
????<input?type="button"?value="顯示內容"?onclick="show()">
????<input?type="button"?value="取消設置"?onclick="cancel()">
??</form>
??<script?type="text/javascript">
//定義"改變顏色"的函數(shù)
function?changec()
{
????var?p=getElementById("txt");
????p.style.color="bule";
}
//定義"改變寬高"的函數(shù)
function?changew()
{
????var?p=getElementById("txt");
????p.style.height="200px";
????p.style.width="300px";
}
//定義"隱藏內容"的函數(shù)
function?hide()
{
????var?p=getElementById("txt");
????p.style.display="none";
}
//定義"顯示內容"的函數(shù)
function?show()
{
????var?p=getElementById("txt");
????p.style.display="block";
}
//定義"取消設置"的函數(shù)
function?cancel()
{
????var?p=getElementById("txt");
????var?massage=confirm("是否取消?");
????if?(massage==true)
????{
????????p.removeAttribute("style");
????????
????}
}
??</script>
</body>
</html>
2017-09-02
有語法錯誤
p=document.getElementById("txt");
而且還有拼寫錯誤
blue
打開控制臺 自己看一下