get parent element - Download Get The Parent Of An Element - jQuery commonParent.js

Download Get The Parent Of An Element – jQuery commonParent.js

Posted on

This time I will share jQuery Plugin and tutorial about Get The Parent Of An Element – jQuery commonParent.js, hope it will help you in programming stack.

get parent element - Download Get The Parent Of An Element - jQuery commonParent.js
File Size: 3.36 KB
Views Total: 935
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

commonParent.js is a small yet useful jQuery plugin for developers that have the ability to get the closest parent (or all parent elements) of a given element for testing/debugging use.

How to use it:

1. Insert the jQuery JavaScript library and the commonParent.js script into the document.

2         integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ"
3         crossorigin="anonymous">
4 </script>
5 <script src="jquery.commonparent.js"></script>

2. Get the closest parent of a given element and output the result in the console.

1 <div class="container">
2   <div class="row">
3     <div class="col-md-4 <a href="https://www.jqueryscript.net/tags.php?/grid/">grid</a>">
4       ... content here ...
5     </div>
6   </div>
7 </div>
1 var instance = $('.grid').commonParent();
2 console.log(instance);

3. Get all the parent of a given element and output the result in the console.

1 var instance = $('.grid').commonParents();
2 console.log(instance);

4. Determine whether or not to exclude the current element in the result.

1 $('.grid').commonParent(true);
2 $('.grid').commonParents(true);

This awesome jQuery plugin is developed by dkline03. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net