www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to get first child when i click second child of element

  1. #1
    Join Date
    Jun 2013
    Posts
    33

    how to get first child when i click second child of element

    Code:
    $(".selection td:first-child + td").click(function(){
              });
    in this code i select the second child of <td>....Now i want the first child of the <td> which user clicked.

    i did this..

    Code:
    $(".selection td:first-child + td").click(function(){
    var first_child_of_selected_column = $(".selection td:first-child").text();
    });
    but couldnt get the result.
    pls help.thnks

  2. #2
    Join Date
    Mar 2009
    Posts
    510
    var x = document.getElementById("myId").previousSibling;

    It returns the previous sibling or NULL if there isn't one.

  3. #3
    Join Date
    Sep 2013
    Posts
    221
    Try out with the below code. I have used it and it works fine for me.
    $('#top > :nth-child(2)').whatever();
    or

    $('#top').children(':first-child').next().whatever();
    Hope this helps you.
    Thnxs.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles