tmartin314
tmartin314

Reputation: 4171

Simple jquery slideup function

I'm calling this function but I need to slideup the parent div of the link that was clicked.

This function is called from a normal link:

function close(){
    $(this).slideUp('slow', function() {

    });
}

How do i reference the element that was clicked (link), then get it's grandparent? I want to slideup not this links parent div, but the parent div of the link div.

I hope that makes sense.

Upvotes: 0

Views: 825

Answers (4)

tmartin314
tmartin314

Reputation: 4171

This is what worked:

onclick="javascript:$(this).parent().slideUp('slow');"

Upvotes: 1

netadictos
netadictos

Reputation: 7722

It would be: $(this).parent().slideUp(....)

Upvotes: 2

Anatoly G
Anatoly G

Reputation: 4152

What this function does is:

  1. binds the click on an element
  2. when element is clicked, its parent slides up

so:

function close(){
   $('elementToSlideUp').click(function(evt) {
       jQuery(this).parent().slideUp('slow');
   });
}

Upvotes: 0

Mouhannad
Mouhannad

Reputation: 2209

Is this what you are looking for?

$('div > a').click(function() {
    $(this).parent().slideUp('slow', function() {

    });
});

Upvotes: 0

Related Questions