為何鼠標(biāo)移到標(biāo)簽上不變色
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> 鼠標(biāo)經(jīng)過事件 </title>
<script type="text/javascript">
? ? function message(){
? confirm("請輸入密碼后,再單擊確定!");?
? ? ?}
? ? ?function click(){
? ? ? ? ?var mychar =document.getElementsByName("title")[0];
? ? ? ? ?mychar.style.color="red";
? ? ?}
</script>
</head>
<body>
<form>
<label name="title" style="color:balck">密碼:</label><input name="password" type="password" onmounseover="click" >
<input name="確定" type="button" value="確定" onmouseover="message()"/>
</form>
</body>
</html>
2016-04-20
2016-02-28
你要的應(yīng)該是這種效果吧
2015-12-22
<script type="text/javascript">
? ? function message(){
? confirm("請輸入密碼后,再單擊確定!");?
? ? ?}
? ? ?function clicks(){
? ? ? ? ?var mychar = document.getElementsByName("title")[0];
? ? ? ? ?mychar.style.color="red";
? ? ?}
</script>
<form>
<label name="title" style="color:black">密碼:</label>
<label name="title" style="color:black">密碼:</label>
<input name="password" type="password" onmouseover="clicks()" >
<input name="確定" type="button" value="確定" onmouseover="message()"/
</form>
經(jīng)測試沒有問題?
你的問題
click屬性名不可當(dāng)作函數(shù)名來用 我改成clicks
你用到的“getElementsByName”不能單個(gè)使用
看例子:http://www.w3school.com.cn/jsref/met_doc_getelementsbyname.asp
我復(fù)制了一個(gè)就可以獲取到第一個(gè)name值為title的元素了
你這里的問題?onmounseover="click" ?調(diào)用函數(shù)得有括號
2015-11-26
style="color:balck" ? 你這個(gè)black ?寫錯了 ? ?這里和你的程序沒有關(guān)系
onmounseover="click" ? 這里click后面沒有加括號?
input好像不會觸發(fā)?onmounseover 事件 ,所以就算程序都寫對也沒有用