get unique text from li
source link: https://www.codesd.com/item/get-unique-text-from-li.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
get unique text from li
Here is the Fiddle. I am making my own custom drop down box (because I want to style it), and I am having trouble getting the unique text of an <li>
. The reason I want to do this is: in default drop down boxes, it shows the text of what you clicked in the box. To be more specific, I am trying to get text from the <li>
you clicked, and put it in the <div id='click'>
.
jQuery:
$(document).ready(function () {
$('ol').hide();
$('#click').click(function () {
$(this).toggleClass('down');
$('ol').toggle();
$('.l').click(function () {
});
});
});
In your $('.l').click()
function
Change:
var l = $('.l').html();
var l = $(this).html();
Incidentally, it is not recommended to use class/ID names that are also methods/commands. (Eg. #click)
I also updated the jsFiddle link to demonstrate showing/hiding the dropdown after selection
Related Articles
How do I get unique records from the database?
How to get HTML text from Adobe Flex Builder RichTextEditor?
Who to get the text from ckeditor with Visual Basic
How do I get multiple texts from two sets of parentheses?
Android: How to get the text from the button when you click on it?
vba: get unique values from the array
JavaScript - get the text from the text box on another page
Get the text from Html.DropdownListFor & hellip; MVC3
A quick way to get unique values from iterators
How to get unique values from the data array using dql?
regex gets the text from the following line
How to get similar text from many pages?
How to get random text from lorem Ipsum in PHP?
Error trying to get the text from the asp.net (C #) text window from ajax static WebMethod
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK