Pages

Showing posts with label Jquery parent element. Show all posts
Showing posts with label Jquery parent element. Show all posts

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 :)