0
I’m starting in Javascript, and would like my DropDownList
of a control .ascx
, when selecting an item, display its full value when you hover over it, as if it were a tooltip or title.
This is my Dropdown:
<asp:DropDownList CssClass="dropdown" ID="ddlDescricao
OnSelectedIndexChanged="ddlDescricao_SelectedIndexChanged"
runat="server" TabIndex="0">
I tried to do it that way:
<script type="text/javascript">
function addToolTip() {
var ddl = document.getElementById('<%= ddlDescricao.ClientID %>');
for (var i = 0; i < ddl.options.length; i++) {
ddl.options[i].title = ddl.options[i].text;
}
}
</script>
But it’s not working.
I’m using jQuery 1.7
From Now Thank You All.
--Edit 11/02/2016 08:27
I’m calling the function from the dropdown onmouseover.
Good afternoon, thanks at first it worked, however, when there is more than one dropdown on the page, it gives an "append" in the values of Tittle, for example the value of dropdown1 is carlos, the value of dropdown2 is twenty, in dropdown2 the "title" will be like carlosvinte, instead of just "twenty".
– Carlos Henrique
I changed the answer
– Felipe Assunção
Good morning Felipe, thanks for the reply, but unfortunately it happens practically the same, see in the image of the edition attached.
– Carlos Henrique