Bram Vanroy
Bram Vanroy

Reputation: 28505

Setting a margin based on a variable added to a number

I'm trying to have the margin-bottom of an element being altered to the height of the next() element plus 12px. I tried the following, but this doesn't work.

$("div.entry-content").css("margin-bottom", $(this).next().outerHeight() + 12 + "px");

Any idea what goes wrong?

Upvotes: 2

Views: 82

Answers (1)

Ram
Ram

Reputation: 144709

Try this:

$("div.entry-content").css("margin-bottom", function(){
    return $(this).next().outerHeight() + 12 + "px"
})

Upvotes: 3

Related Questions