开发者

jquery width() with newly generated element

开发者 https://www.devze.com 2023-03-21 22:42 出处:网络
When I use the following : div = \'<div class=\"tag-tooltip\" id=\"tooltip_view_1\">First item</div>\';

When I use the following :

div = '<div class="tag-tooltip" id="tooltip_view_1">First item</div>';
$('#products').append(div);

var tooltip_width = $('开发者_如何学编程#tooltip_view_1').width(); 
var tooltip_height = $('#tooltip_view_1').height();

The tooltip_height gives a correct value, while tooltip_width returns 0. Any idea why is this happening and what should I do to get the width of the newly created element?


Just to say I've solved the problem - it appears css property : text-indent is also affecting visibility of the element. I had it set to the negative value and once removed this property altogether - everything started working fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消