有沒有什麼辦法可以做到這一點,不使用:懸停和不在所有元素中添加「onmouseover和onmouseout」,就像一個腳本中的有效方法巫婆設置onmouseover併爲所有輸入元素提供上傳。JavaScript - 爲多個元素設置onmouseover而不使用:hover
注意:請用JavaScript嘗試使用jQuery試圖
<head>
<title>123</title>
<style>
.button {
color: red;
}
.button:hover {
color: blue;
}
</style>
</head>
<body>
<div>
<input class="button" type="button" value="1">
<input class="button" type="button" value="2">
<input class="button" type="button" value="3">
</div>
</body>
是的,但如果我想幹什麼來設置顏色:this.style.color =「紅色」應如何界定我的呢? – Murplyx 2013-02-09 10:55:12
你可能要仔細檢查你的for循環。你應該真的使用一個傳統的for循環而不是for..in,但是即使忽略你不使用循環內的我... – nnnnnn 2013-02-09 10:55:51
@nnnnnn oops,thanks :) – Manishearth 2013-02-09 10:56:38