這段哪里錯了,點確定后顏色沒變
var cC=document.getElementById("txt"); ? ? ?function cc(){ ? ?var changColor=confirm("是否改變顏色?");//定義"改變顏色"的函數(shù) ? ?if(changeColor==ture) ? ?{ ? ? ? ?cC.style.color="red"; ? ? ? ?cC.style.backgroundColor="#ccc"; ? ?} ?}
var cC=document.getElementById("txt"); ? ? ?function cc(){ ? ?var changColor=confirm("是否改變顏色?");//定義"改變顏色"的函數(shù) ? ?if(changeColor==ture) ? ?{ ? ? ? ?cC.style.color="red"; ? ? ? ?cC.style.backgroundColor="#ccc"; ? ?} ?}
2017-07-22
舉報
2017-07-24
onclick ="cc()"
2017-07-24
定義了啊
2017-07-22
可能是之前input按鈕里面沒有定義onClick方法,執(zhí)行script語句的時候這個方法找不到入口。