3

get unique text from li

 2 years ago
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

advertisements

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 () {

        });
    });
});


Working jsFiddle here

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 can I get unique records from database by linq? For example: I have something like that 07.12.2016 07.12.2016 08.12.2016 08.12.2016 10.12.2016 I would like to have something like that 07.12.2016 08.12.2016 10.12.2016 My query: var query2 = (from

How to get HTML text from Adobe Flex Builder RichTextEditor?

How to get HTML text from inputed and edited text into Adobe Flex Builder RichTextEditor control? I mean with valid HTML coming from the Flex RichTextEditor component Not Badly formated HTML, with no spaces, with tags not closed! So we have some text

Who to get the text from ckeditor with Visual Basic

I have a problem with the ckeditor and visual basic (using visual studio). I have an .html page with the scrip for use ckeditor, this part is ok, I use a webbrowser for navigate to the web, and can set text with the DocumentCompleted event. The probl

How do I get multiple texts from two sets of parentheses?

I need to get multiple texts from more than one set of parentheses, and if there is no more than one set then I need to get text from only that single set of parentheses. 1) Example : My sentence is : A Cef (1000mg) (Sterlie Ceftriaxone) Price List.

Android: How to get the text from the button when you click on it?

This question already has an answer here: get text from pressed button 3 answers for( i=0; i<26; i++) { btnAlpha[i] = new Button(this); btnAlpha[i].setBackgroundColor(Color.TRANSPARENT); btnAlpha[i].setTextColor(Color.GREEN); btnAlpha[i].setText(Char

vba: get unique values ​​from the array

is there built in functionality in vba to get unique values from a one-dimensional array? what about just getting rid of duplicates? if not, then how would i get the unique values from an array?This post contains 2 examples. I like the 2nd one: Sub u

JavaScript - get the text from the text box on another page

I want to fill an array by parsing values from a text area, div, etc. on another page on the same site. (Poor man's database.). It is a hosted site, so all I have is JavaScript, no jquery, much less php, etc. I can do the parsing, but first I have to

Get the text from Html.DropdownListFor & hellip; MVC3

I have a model: public class DocumentModel { public int TypeID { get; set; } public List<SelectListItem> DocumentTypes { get; set; } } I have a view: @Html.DropDownListFor(x => x.TypeID, Model.DocumentTypes, "- please select -") I popul

A quick way to get unique values ​​from iterators

It is well known that iterators show a better performance than common list comprehensions: In [8]: from random import random In [10]: %timeit [random() for i in range(10000000)] 1 loops, best of 3: 883 ms per loop In [11]: %timeit (random() for i in

How to get unique values ​​from the data array using dql?

I am having a table in which there is a column in which various values are stored.i want to retrieve unique values from that table using dql. Doctrine_Query::create() ->select('rec.school') ->from('Records rec') ->where("rec.city='$city' &qu

regex gets the text from the following line

I'm looking for a way to find text on the next line of a certain string using regex. Say I have the following text: Note: Just some text on this line Some more text here. I just want to get the text 'Just some text on this line'. I don't know exactly

How to get similar text from many pages?

get the x most similar texts from a lot of texts to one text. maybe change the page to text is better. You should not compare the text to every text, because its too slow.I don't know what you mean by similar, but perhaps you ought to load your texts

How to get random text from lorem Ipsum in PHP?

I want the random text from Lorem Ipsum so I can use it when generating webpages. I can't find any PHP functions that does this and I'm wondering if there's any publicly available libraries or APIs on sites that could be used to get some random text?

Error trying to get the text from the asp.net (C #) text window from ajax static WebMethod

I am using an ajax htmleditor in asp.net web application so i am trying to get the text the user has entered in the editor then i will send that text back to the client javascript function that will show the text in a div. But I am getting this error

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK