Get value from list item on ol list click function

VSN

I need to get value form every list click

Here is my list:

<c:forEach items="${cmlist}" var="records"> 
   <ol class="dd-list"  id="chapterlist" >
      <li id="cs" class="dd-item" data-id="1" value="${records.levelID}">
         <div class="dd-handle">
            <a href="#subchaptercontent">Chapter:  ${records.levelName}</a> 
         </div>
      </li>
   </ol>
</c:foreach>

here is my click function code:

$(window).load(function(){
   $("#chapterlist li a").on("click", function(){
      level =  $(this).parent('li').val();
      console.log("level"+level);
   });
});

Could you please help?

Ray Poward

parent() function only goes up one level of DOM, so it gets to your <div> element and stops there. Use parents() instead.

JSFiddle

Note, that val() will only work if value is an integer. Shouldn't be a problem with an ordered list, though, where value is the number of an item.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get value from list item on list click function

From Dev

Get attribute value from a selected item in a list

From Dev

Get attribute value from a selected item in a list

From Java

How to get value of a list item that is generated automatically on click

From Dev

OnItemClick how to get text value of clicked item from list view

From Dev

Android Listview, on click get name of item in list

From Dev

fetching value from list on click

From Dev

Get an item randomly from a list

From Dev

how to set value list item in adapter class and get value on Button click in android

From Dev

how to set value list item in adapter class and get value on Button click in android

From Dev

Setting image from url on List item click

From Dev

Get value of List Item inside of list Item Javascript

From Dev

how to get a particular column value from a list view on click of a row from that list view?

From Dev

Fetching List Item Click

From Dev

Single Item Click in a list

From Dev

Fetching List Item Click

From Dev

How to get string value of a List<t> Item

From Dev

SharePoint 2013 get list item field value

From Dev

Get index value of nested list item with jQuery

From Dev

Get the index of item in list based on value

From Dev

Java - get the value of selected list item

From Dev

Get the pair with max value from list in a list

From Dev

Is there an exposed function for removing an item from a list?

From Dev

Return Item from List with Minimum Value

From Dev

Matching a value to an item taken from a dropdown list

From Dev

How to get selected value of list item in radio button list in jquery

From Dev

Get value from List<ListObject>

From Dev

change value from array list on click

From Dev

Get last item from a list as integer/float

Related Related

  1. 1

    Get value from list item on list click function

  2. 2

    Get attribute value from a selected item in a list

  3. 3

    Get attribute value from a selected item in a list

  4. 4

    How to get value of a list item that is generated automatically on click

  5. 5

    OnItemClick how to get text value of clicked item from list view

  6. 6

    Android Listview, on click get name of item in list

  7. 7

    fetching value from list on click

  8. 8

    Get an item randomly from a list

  9. 9

    how to set value list item in adapter class and get value on Button click in android

  10. 10

    how to set value list item in adapter class and get value on Button click in android

  11. 11

    Setting image from url on List item click

  12. 12

    Get value of List Item inside of list Item Javascript

  13. 13

    how to get a particular column value from a list view on click of a row from that list view?

  14. 14

    Fetching List Item Click

  15. 15

    Single Item Click in a list

  16. 16

    Fetching List Item Click

  17. 17

    How to get string value of a List<t> Item

  18. 18

    SharePoint 2013 get list item field value

  19. 19

    Get index value of nested list item with jQuery

  20. 20

    Get the index of item in list based on value

  21. 21

    Java - get the value of selected list item

  22. 22

    Get the pair with max value from list in a list

  23. 23

    Is there an exposed function for removing an item from a list?

  24. 24

    Return Item from List with Minimum Value

  25. 25

    Matching a value to an item taken from a dropdown list

  26. 26

    How to get selected value of list item in radio button list in jquery

  27. 27

    Get value from List<ListObject>

  28. 28

    change value from array list on click

  29. 29

    Get last item from a list as integer/float

HotTag

Archive