joomsch
joomsch

Reputation: 11

add style attribute with value

I was wondering if its possible to add a style tag with div height discovered by jquery .height()

Example:

<div class="divheight"></div>
<div class="divheight"></div>

What I want to:

<div class="divheight" style="height:(heightofdiv)">   
<div class="divheight" style="height:(heightofdiv)">   

My jquery which delivers the heightofdiv:

$('.result').show (function () {
$(document.body).append($(this).height());
});

Any Ideas ?

Upvotes: 1

Views: 65

Answers (1)

VladL
VladL

Reputation: 13033

I can't really see how heightofdiv is calculated in your code, but if it's set, simply use following code

$('.divheight').css('height', heightofdiv);

This one line will set all divs containing the class divheight

Upvotes: 2

Related Questions