facebook

little bit of jquery help. 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 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #330372 Reply

    SonamGyato
    Member

    var obj = list.children(‘#app-listItem1’);

    how can i find out the number of children.

    obj.length returns 2 always.

    also how can i index the list/array.

    thanks.

    #330373

    support-michael
    Keymaster

    Without seeing your exact code it is hard to tell what might be up. But my first thought is the children(selector) is not correct. I used find(selector).

    Here are some snippets that I ran in the Test Center javascript console that might be helpful.
    See attachment jquery-listitem-selection.png

    Attachments:
    You must be logged in to view attached files.
    #330378

    SonamGyato
    Member

    thanks.

    list.children().length worked

    i was trying list.children.length

    #330381

    SonamGyato
    Member

    i’d like to modify the CLASS attribute of the 1st entry in the list object.

    list.children(0).setAttribute( “class”, “xxx” );

    does not work.

    how do i get access to the underlying DOM element.

    thanks.

    #330383

    support-michael
    Keymaster

    >list.children(0).setAttribute( “class”, “xxx” );

    Q: what type of object is “list” and how are you looking it up?

    If “list” is an array use standard javascript array indexing syntax, myarray[0] to access the 1st element of the array.

    list.children()[0] should do the trick. If you run your project in the Test Center, try opening the DOM Inspector. Then in the JS Console at bottom you can manually enter js snippets and run them to see their effect. (See prev response screenshot for an example)

    #330385

    SonamGyato
    Member

    list.children().first().addClass(“XX”);

    solved it.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: little bit of jquery help. CLOSED

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