簡體   English   中英

在鼠標懸停選擇菜單上更改顏色

[英]change color on mouseover select menu

我正在嘗試選擇一個多選組合框。 我必須自定義屬性,當將鼠標懸停在某個值上時,顏色必須更改。 我嘗試了幾個步驟,我知道它不起作用。 向我建議我應該如何處理。 這是代碼。

<html>
<head>
<style type="text/css" >

</style>
<script type="text/javascript">
var a="hidden";
function doset()
{
    if(a=="hidden")
    a="visible";
    else
    a="hidden";
    document.getElementById("myitems").style.visibility = a; 
}
function dochange(a)
{

    document.getElementById(a).style.background-color= 0xff00ff; 
}
</script>
</head>
<body>
<label>ajay</label>
<input type=button value="v" onClick="doset(); return false;"/>
<div id=myitems style='visibility:hidden'>
<select multiple="multiple" >
<option id= prav1 onMouseover="dochange(this.id); return true;">ajay</option>
<option id= prav2 onMouseover="dochange(this.id); return true;">musthafa</option>
<option id= prav3 onMouseover="dochange(this.id); return true;">praveen</option>
<option id= prav4 onMouseover="dochange(this.id); return true;">shruthy</option>
<option id= prav5 onMouseover="dochange(this.id); return true;">vasanth sir</option>
</select>
</div>
</body>
</html>

它是backgroundColor而不是background-color

document.getElementById(a).style.backgroundColor= "#ff00ff";

查看工作演示

document.getElementById(a).style.background =“#ff00ff”;

function dochange(a) 
{ 
  document.getElementById(a).style.backgroundColor = "#ff00ff";  
} 

“ document.getElementById(a).style.background-color”錯誤必須是:“ document.getElementById(a).style.backgroundColor”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM