开发者

jquery width() with newly generated element

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜