0
我想添加onmouseover到选项标签来显示文本值。有人可以帮助我吗?如何在JavaScript中添加onmouseover属性到<OPTION></OPTION>?
var opt;
for (var i = 0; i < response.length; ++i)
{
var tempResult=new Array();
tempResult=response[i].split('|');
opt = document.createElement("OPTION");
opt.text = tempResult[1];
opt.value= tempResult[0];
opt.title = tempResult[2];
opt.attributes.add
matchList.options.add(opt);
}
默认显示文本值,为什么onmouseover? – Imad
请参阅[* MDN:addEventListener *](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)。选项元素的鼠标悬停事件在多选时才有意义。请注意,由于键盘导航不会触发鼠标悬停,或者可能存在[* ARIA属性*](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/WAI-ARIA_basics),因此无法访问它。为了那个原因。 – RobG