能幫我看看哪里出錯(cuò)了嗎?
<form>
??? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
??? <input type="button" value="改變顏色" onClick="Co()">
??? <input type="button" value="改變寬高" onClick="Ds()">
??? <input type="button" value="隱藏內(nèi)容" onClick="Hi()">
??? <input type="button" value="顯示內(nèi)容" onClick="Ap()">
??? <input type="button" value="取消設(shè)置" onClick="De()">
</form>
<script type="text/javascript">
??? function Co(){
??????? var p1=document.getElementById("txt");
??????? p1.style.color="red";
??????? p1.style.backgroudColor="#cc3656";}//定義"改變顏色"的函數(shù)
??? function Ds{
??????? var p1=document.getElementById("txt");
??????? p1.style.width="100px";
??????? p1.style.height="100px";}//定義"改變寬高"的函數(shù)
??? function Hi(){
??????? var p1=document.getElementById("txt");
??????? p1.style.display="none";}//定義"隱藏內(nèi)容"的函數(shù)
??? function Ap{
??????? var p1=document.getElementById("txt");
??????? p1.style.display="block";}//定義"顯示內(nèi)容"的函數(shù)
??? function De(){
??????? var mychar=confirm("是否取消設(shè)置");
??????? if(mychar){
??????????? var p1=document.getElementById("txt");
??????????? p1.style.color="red";
??????????? p1.style.backgroundColor="#cc3656";
??????????? p1.style.width="100px";
??????????? p1.style.height="100px";
??????????? p1.style.display="none";
??????? }//定義"取消設(shè)置"的函數(shù)
2017-09-05
Co()中backgroundColor少個(gè)n,funtion De()結(jié)束少半拉右大括號(hào)
2017-09-05
onclick,注意大小寫。
取消設(shè)置只需用removeAttribute移除所有的style設(shè)置即可:document.getElementById("txt").removeAttribute("style");
2017-09-05
Ds和Ap函數(shù)少了括號(hào)