0

This is the code:

$.get('test.php',
function(data){
   var black_html = "<span class='wrap-content'>"+data+"</span>";

   $('body').after(black_html);

   console.log( $('.wrap-content').height() );
});

In firefox, I'm getting the correct value: 468px, but in Chrome I'm getting 0.

Zbarcea Christian
  • 9,367
  • 22
  • 84
  • 137
  • I don't understand why - if you change the `.height()` to `.length` do you get 1 or 0? A little more info would be good in order to allow us to help you – Ian Clark Aug 18 '13 at 13:06
  • In firefox I'm getting 1, in Chrome 0. – Zbarcea Christian Aug 18 '13 at 13:09
  • I think @Nirazul has the correct answer, in general you should try to output the jQuery object and see if it contains anything, if it doesn't then you know that's the problem rather than there being no height etc. – Ian Clark Aug 18 '13 at 13:13

1 Answers1

3

You are trying to append DOM-Elements after the body tag. This may be part of the problem. You aren't allowed to do that. You content must go inside of the body-tag.

Try:

$('body').append(black_html);

See also this question: Is it wrong to place the <script> tag after the </body> tag?

Community
  • 1
  • 1
nirazul
  • 3,928
  • 4
  • 26
  • 46
  • `.wrap-content { display:table; overflow:hidden; }` was the trick, now it's working – Zbarcea Christian Aug 18 '13 at 13:16
  • if you got length 1 in firefox and in chrome 0, then "this" was not the trick ;). even if it's working now, you shouldn't add dom nodes after the body tag. – nirazul Aug 18 '13 at 15:14