<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>display</title><script type="text/javascript">function hidetext(){var mychar=document.getElementById("con").style.display="none";}function showtext(){? var mychar=document.getElementById("con")? mychar=style.display="block";}</script></head><body><p id="con">這是我的第一個dom練習代碼</p><form><input type="button" onclick="hidetext" value="不顯示段落內容" /><input type="button" onclick="showtext" value="顯示內容" /></form></body></html>為什么不能隱藏和顯示?。??問題出在哪里?
3 回答

寒江北去
TA貢獻3條經驗 獲得超2個贊
<input type="button" onclick="hidetext" value="不顯示段落內容" />
<input type="button" onclick="showtext" value="顯示內容" />
改正后應該是
<input type="button" onclick="hidetext()" value="不顯示段落內容" />
<input type="button" onclick="showtext()" value="顯示內容" />
onclick后邊引號里寫的是函數的名字,既然是函數,那么()就是不可少的
- 3 回答
- 0 關注
- 1603 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消