Reputation: 483
<ul class="dropdown-menu" id="neither_nor_selector" style="text-decoration: none;left: 18%;min-width: 65px;">
<li><a title="neither">neither</a></li>
<li><a title="nor">nor</a></li>
</ul>
How to display the selected list item text
$("#neither_nor_selector option:selected").text()?
Upvotes: 1
Views: 837
Reputation: 14216
You could do something like this if you did not want to use a select.
$(".dropdown-menu li").on("click", function(){
//get the text here
var myText = $(this).find("a").text();
console.log(myText);
});
This will just hook onto clicking any of the li's (i'm not sure what event your using to select so it could change i guess). and then you can do with it what you need.
Alternatively you could just re-style the select tag to look how you please (assuming you want a real dropdown here).
Example fiddle - https://jsfiddle.net/v53aubL3/
Upvotes: 1
Reputation: 171
You can assign a class to anything and then give each element a different id:
<li class="foo" id="first"><a title="neither">neither</a></li>
<li class="foo" id="nor"><a title="nor">nor</a></li>
js:
$(".foo").click(function() {
var bar = $(this).attr('id');
alert(bar);
});
Upvotes: 0