javascript - jquery get height of div -
i have 3 divs.
<div class="bg1"></div> <div class="bg2"></div> <div class="bg3"></div>
and i'm trying heights of them , set css jquery.
$('[class^=bg]').each(function(key,val){ // tried, val.height() val.outerheight val.innerheight, this.height() etc });
console.log(val)
shows <div class="bg1"></div>
instead of jquery object, how go getting , changing height of each div in loop?
you're correct functions don't work because val
dom object instead of jquery object. can effect want converting each val
dom object jquery object wrapping $()
.
this code should work way want:
$('[class^=bg]').each(function(key,val){ $(val).height(); // or $(val).height(100) etc. });
Comments
Post a Comment