為什么不輸出?
function chancolor (){
??????? var azs = document.getElementById("txt");
??????? azs.style.color="red"
??????? }
??? function chanwidth (){
??????? var azs = document.getElementById("txt");
??????? azs.style.width="500px"
??????? }
??? function chanwss (){?? ?
??????? var azs = document.getElementById("txt");
??????? azs.style.display="none"}
???? function chanwsc (){ ?
??????? var azs = document.getElementById("txt")
??????? azs.style.display="block"
???? }
??? function aa(){
??????? var? aa == comfirm("是否取消設(shè)置");
??????? if(aa=true){
????????? aa=? txt.removeAttribute('style')
??????? }
??????? }
??? }
2016-11-02
幾點問題:
注意onclick事件必須要加,這個在樓里的回復(fù)見你已經(jīng)加上了
注意定義完變量一定要加分號“;”,不加是語法有誤
顯示內(nèi)容的onclick事件和定義函數(shù)有微小差異,所以事件無法響應(yīng)
定義變量aa是不要用==,這個是等于,不是賦值
最大的坑,你最下邊多了個右大括號“}”,有了結(jié)尾卻找不到開始。
2016-11-02
function chancolor (){
? ? ? ? var azs = document.getElementById("txt")
? ? ? ? azs.style.color="red"
? ? ? ? }
? ? function chanwidth (){
? ? ? ? var azs = document.getElementById("txt")
? ? ? ? azs.style.width="500px"
? ? ? ? }
? ? function chanwss (){ ? ?
? ? ? ? var azs = document.getElementById("txt")
? ? ? ? azs.style.display="none"}
? ? ?function chanwsc (){ ?
? ? ? ? var azs = document.getElementById("txt")
? ? ? ? azs.style.display="block"
? ? ?}
? ? function aa(){?
? ? ? ? var ?ab=confirm("是否取消設(shè)置");
? ? ? ? if(ab==true){
? ? ? ? ? var azs = document.getElementById("txt")
? ? ? ? ? azs.removeAttribute('style');
? ? ? ? }
? ? ? ? }
//第一個問題,你的賦值=和判斷等號在aa函數(shù)那里使用反了。
//第二個你confirm那句重新輸入一下,注意一下中文還是英文,我重新輸了一下就好了。
//還有就是你txt沒又定義就使用了。
2016-11-02
?<form>
? <!--當(dāng)點擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
??? <input type="button" value="改變顏色"? onclick="chancolor()"> ?
??? <input type="button" value="改變寬高"? onclick="chanwidth()">
??? <input type="button" value="隱藏內(nèi)容" onclick="chanwss()">
??? <input type="button" value="顯示內(nèi)容" onclick="chanwas()">
??? <input type="button" value="取消設(shè)置" onclick="aa()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
? ?
//定義"改變寬高"的函數(shù)
??? function chancolor (){
??????? var azs = document.getElementById("txt")
??????? azs.style.color="red"
??????? }
??? function chanwidth (){
??????? var azs = document.getElementById("txt")
??????? azs.style.width="500px"
??????? }
??? function chanwss (){?? ?
??????? var azs = document.getElementById("txt")
??????? azs.style.display="none"}
???? function chanwsc (){ ?
??????? var azs = document.getElementById("txt")
??????? azs.style.display="block"
???? }
??? function aa(){
??????? var? aa? == comfirm("是否取消設(shè)置")
??????? if(aa=true){
????????? aa=? txt.removeAttribute('style')
??????? }
??????? }
??? }
還是不行啊
2016-11-02
<input type="button" onclick = 'chancolor()' value="改變顏色" >?