Get the dropdown title in jquery

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hi Experts,
 @Html.FacetDropDownList("ID", Model.ID, new { @class = "special-dropdown", title = T("Select a student").Text })

Open in new window


Is there anyway I can access this title in jquery?

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Yes - two ways I can see.

The one is by the class

$('.special-dropdown');

Open in new window

The other by the id
$('#<%=Model.ID%>');

Open in new window


We would need to know
a) How this component renders in the HTML page
b) What you want to do with the it

To be able to give you more.

Can you post what the rendered HTML looks like and let us know what you want to do with the title - do you just want to get the text?

Author

Commented:
Thank you for trying to help me!
This is how it is rendered.
<input id="StudentType" name="StudentType" type="hidden" value="Regular" />    <div style="display:none;">
<div id="StudentDiv">
<div class="facet-dropdown"><select class="special-dropdown test-dropdown" id="StudentId" name="StudentId" title="Select a student">
<option value="9999">Test1</option>
<option value="8888">Test2</option>
<option value="8881">Test3</option>
</select>
</div>

</div>
    
</div>

Open in new window


I want that title -"Select a student"
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Then you can do this for jQuery
$('#<%=Model.ID>').attr('title');

Open in new window

And this for plain JavaScript
document.getElementById('<%=Model.ID%>').title);

Open in new window

Author

Commented:
Thank you very much!! It worked!
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial