Member Avatar for ShandyElliott

I have a drop down menu with options. Is there a faster way to display a tool tip based on the value of the <option> tag other than having to manually set title="" for each <option> tag?

You can do it with script, but you still have to write all the tooltips. Do you want all the same or different tooltips?

Member Avatar for ShandyElliott

You can do it with script, but you still have to write all the tooltips. Do you want all the same or different tooltips?

The tool tip will be based on the value of the option tag's value (as stated). If the value of an option = "Walnut", then I want the tool tip to read "Walnut" when that option is hovered.

I get it.

<body>
<select>
  <option class = 'volvo' value="volvo">Volvo</option>
  <option class = 'saab' value="saab">Saab</option>
  <option class = 'mercedes' value="mercedes">Mercedes</option>
  <option class = 'audi' value="audi">Audi</option>
</select>
<script type='text/javascript'>
$(document).ready(function(){
	$("select option").each(function(){
		var title = $(this).attr('value');
		$(this).attr("title", title);
	});
});
</script>
</body>

Now you got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.