點擊怎么沒反應
!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
? ? <input type="button" value="改變顏色" onclick="color()"> ?
? ? <input type="button" value="改變寬高" onclick="top()">
? ? <input type="button" value="隱藏內容" onclick="display()">
? ? <input type="button" value="顯示內容" >
? ? <input type="button" value="取消設置" >
? </form>
? <script type="text/javascript">
?var mychar=document.getElementById("con");
? var txtchar=document.getElementById("txt");
//定義"改變顏色"的函數
function color()
{
? ? mychar.style.color="red";
? ? txtchar.style.backgroundColor="#D1BDA1";
}
function top() {
? ? txtchar.style.width="200px";
? ? txtchar.style.heigth="200px";
}
function display()
{
?txtchar.style.display="none";
}
2016-07-28
應該是 onClick="" 那里的c沒大寫
2016-08-01
function ?我換了個函數名就可以了 不知道是不是用了關鍵字命名函數
2016-07-28
不對喲。我用你這個代碼跑的動呢。你可能哪里出問題吧,那些標簽有對應嗎?這些代碼內容基本沒啥問題。另onclick剛查了和測試一下也沒區分大小寫。。
2016-07-28
<form>
<input type="text" id="con" value="Test"></input>
<input type="text" id="txt" value="Test"></input>
? ?<input type="button" value="改變顏色" onclick="color()"> ?
? ? <input type="button" value="改變寬高" onclick="top()">
? ? <input type="button" value="隱藏內容" onclick="display()">
? ? <input type="button" value="顯示內容" >
? ? <input type="button" value="取消設置" >
? </form>
? <script type="text/javascript">
?var mychar=document.getElementById("con");
? var txtchar=document.getElementById("txt");
//定義"改變顏色"的函數
function color()
{
? ? mychar.style.color="red";
? ? txtchar.style.backgroundColor="#D1BDA1";
}
function top() {
? ? txtchar.style.width="200px";
? ? txtchar.style.heigth="200px";
}
function display()
{
?txtchar.style.display="none";
}
</script>
以上是我測試代碼,可用。
你的代碼少了個<from>開頭,以及你的代碼少了個</script>結束
2016-07-27
onClick C大寫