Reputation: 105
I want to get the width and height of .more class and .popovercontent div using jquery. popover-content class width is dynamic it can be change as i am getting the width from my database. Iam getting the below division by this. so i want to know how to get the width and height using this
console.log(this);
It display the below result
<div id="picture1-more4" class="more more32 ltr-slide bgblack" style="top: 288px; left: 549px; z-index: 1; width: 32px; height: 32px;">
<div class="imgButton imgButtonDrag imgButtonDrag imgButtonDrag imgButtonDrag imgButtonDrag imgButtonDrag imgButtonDrag imgButtonDrag moreblack"></div>
<div class="popover-inner red" style="margin-left:50px;">
<div class="arrow-right3" style="display: inline-block !important; border-left-width: 10px; border-left-style: solid; border-left-color: green; border-top-width: 10px; border-top-style: solid; border-top-color: transparent; border-bottom-width: 10px; border-bottom-style: solid; border-bottom-color: transparent; position: absolute; top: 50%;"></div>
<h4 class="popover-title"><a href="" target="self">Garden</a></h4>
<div class="popover-content" style="width:400px;"><p>To view details about either the Security or Maintenance section, click the heading or the arrow next to the heading to expand or collapse the section. If you dont want to see certain types of messages, you can choose to hide them from view. </p></div>
</div></div>
Upvotes: 0
Views: 47
Reputation: 6525
Well the problem is that you need to specify what $(this)
is.
As you can see in my fiddle i loop through every div, meaning that $(this)
now is the "div" it is looping through at that moment.
but why use $(this)
if you know the classes you want to get the width from?
As said by others this is way easier:
$('.more').width()
$('.popover-content').width()
Upvotes: 1
Reputation: 56
if you are using Jquery, you can try this
var width = $('.test').width();
var height = $('.test').height();
Upvotes: 0