Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Instead of using $('div').parent().parent().parent().parent().addClass('lol')
- // you can use this: $('div').parentx(4).addClass('lol')
- if ( window.jQuery ) {
- jQuery.fn.parentx = function( i ) {
- if ( i > 1 ) {
- var e = $(this);
- for ( var a = 1; a <= i; a++ ) {
- e = e.parent();
- }
- return e;
- }
- return $(this).parent();
- }
- }
Add Comment
Please, Sign In to add comment