How can I show a tooltip for each option on a dropdown with JavaScript or Ajax?

不羁岁月 提交于 2019-12-25 11:33:42

问题


How can I show a tooltip for each option on a dropdown with JavaScript or Ajax?

It is easy to show with the code behind, but this tooltip is not as fast as a tooltip created with JavaScript.


回答1:


You can do something like this with help of javascript by adding this from code behind:

DropDown1.Attributes.Add("onmouseover", 
                         "this.title=this.options[this.selectedIndex].title");

OR

<select name="DropDownList1" id="DropDownList1"
     onmouseover="this.title=this.options[this.selectedIndex].title">
    <option value="1" title="asd">asd</option>
    <option value="2" title="zxc">zxc</option>
    <option value="3" title="qwe">qwe</option>
</select>



回答2:


use this  : 
<select name="ddlCity" id="ddlCity"
     onmouseover="this.title=this.options[this.selectedIndex].title">
    <option value="Delhi" title="Delhi">Delhi</option>
    <option value="mumbai" title="mumbai">mumbai</option>
    <option value="Chennai" title="Chennai">Chennai</option>
    <option value="kolkata" title="mumbai">mumbai</option>
</select>


来源:https://stackoverflow.com/questions/14208907/how-can-i-show-a-tooltip-for-each-option-on-a-dropdown-with-javascript-or-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!