功能是按下按钮,单词如果是good,就变成bad,如果是bad,就变成good /////////////////////////////////////////////////////////////////////////////// <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript"> function changeword(){ var newword=document.getElementsByClassName('word'); if (newword[0]=="good") { newword[0]="bad"; } else{ newword[0]="good"; } } </script> <title>changeword</title> </head> <body> <input type="button" value="changeword" id="abutton" onclick="changeword()"> <p class="word">good</p> </body> </html>
luofuxiang