Reputation: 160
Is it possible to add a hover message on a dropdown menu for each selection using JavaScript?
Would I use something like document.getElementById('name_of_html_id')
followed by one of the four options?
How would I traverse through each HTML option where I would use onmouseover
Upvotes: 1
Views: 506
Reputation: 39777
Just add a title attribute, e.g.
<select id="xMySelect">
<option title="Hovered aaaaaaaaaaa">aaaaaaaaaaa</option>
<option title="Hovered bbbbbbbbbbb">bbbbbbbbbbb</option>
</select>
Demo: http://jsfiddle.net/b7F7T/1/
Or with JS:
var sel = document.getElementById("xMySelect");
sel.options[0].setAttribute('title', 'hovered item 1');
sel.options[1].setAttribute('title', 'Second item hovered');
Demo 2: http://jsfiddle.net/b7F7T/3/
Upvotes: 3