Pages

Thursday 8 November 2012

Jquery parent element selection

JQuery parent element selection is always needed code. Below I have listed how to get parent element in jQuery by tags,class,id etc. 

Try Demo Examples


Get first parent by tag name in jquery


$(“#id”).parent().closest(“DIV”);

Get first parent by id in jquery

$(“#id”).closest(“#id”);

Get first parent by class name in jquery

$(“#id”).closest(“.className”);

Get all parents by tag name in jquery

This will return array of all the parent div elements.
$(“#id”).parents(“DIV”);


Try Demo Examples

Also Check below links
How to select child element in jQuery 

If you found this post useful.Please share and comment. Thanks :)

2 comments:

  1. Can you guess how much these celebrities are worth? Test your knowledge with Celebrity net worthCelebrity net worth.

    ReplyDelete
  2. Making Money by Making Money by Making Money from
    a sports betting strategy to make money in the long งานออนไลน์ run, including online sports betting, casino, poker and roulette. Learn more.

    ReplyDelete