facebook

Get data-key of first li return undefined [CLOSED]

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #336789 Reply

    Yann
    Member

    Hello,
    i have a small problem
    i create via jquery a list

    
    <li data-key="1">One</li>
    <li data-key="2">Two</li>
    <li data-key="3">Three</li>
    

    when i try to get data of last li with

    alert($('#mylist li:last').data('key'));

    return the good value of data-key (3)
    but if i try to get data value of first li

    alert($('#mylist li:first').data('key'));

    return “undefined”

    have you an idea?
    thanks
    EDIT : Solution found $(‘#mylist :first-child li’).data(‘key’);

Viewing 1 post (of 1 total)
Reply To: Get data-key of first li return undefined [CLOSED]

You must be logged in to post in the forum log in