The function I was trying to use wasn’t working, so I tested the length selection (should be one):
$('header').append('<p id="ancho_ventana"></p>');
$(document).ready(function(){
alert(('p#ancho_ventana').length); //outputs "15"
});
Also tried with
var ancho = $('<p id="ancho_ventana"></p>').hide();
$(document).ready(function(){
$(window).bind('resize',function(){
alert(('p#ancho_ventana').length);
})
});
And the second function outputs the same. Why is this happening?
Your
alertreturns the length of the stringp#ancho_ventana, which contains 15 characters.I think you meant: