0

I have a div that has padding only and i have another div without any css attribute.
I want to give the same height to both divs using outerHeight.

This is my test, this works but not perfectly: http://jsfiddle.net/A2bNm/6/

$("#container").mouseenter(function () {
        $("#top").animate({ 'padding' : 70 }, "slow");
        $("#bottom").animate({'height':($("#top").outerHeight())}, "slow");

    }).mouseleave(function () {
        $("#top").animate({ 'padding' : 20}, "slow");
        $("#bottom").animate({'height':($("#top").outerHeight())}, "slow");
});

Can help? Thank you and sorry for my bad english! :)

Mustapha Aoussar
  • 5,833
  • 15
  • 62
  • 107

1 Answers1

1

Try referring to your divs with their current name this and with the other's name .closest('div) or .siblings('div').

http://api.jquery.com/siblings/ http://api.jquery.com/closest/

Also, perhaps store the required height as an independent variable, so it's not based on the #top's current value (which changes).

ericosg
  • 4,926
  • 4
  • 37
  • 59
  • I tried to referring my divs with `this`, but doesn't work! Can you give a jsfiddle example? Thanks! – Mustapha Aoussar Apr 08 '13 at 09:20
  • I was referring to this http://jsfiddle.net/A2bNm/7/ as a usage, without the actual full implementation. note that I'm selecting the children of the container so that $(this) refers to each div. – ericosg Apr 08 '13 at 17:02
  • Thank you veru much! but in the div **#top** and **#bottom** i have other divs, so if i use `$(this)` this refers to all divs. I tried to change `this` to id name, but doesn't work. – Mustapha Aoussar Apr 10 '13 at 10:46
  • What i want to do is to clone the div #top wrapper only. I tried with `.clone` but this clone the whole div (with internal contents). – Mustapha Aoussar Apr 10 '13 at 12:05
  • sorry, i don't understand your issue without some examples. maybe raise another question? – ericosg Apr 10 '13 at 15:00