Thursday, 15 September 2011

javascript - jQuery height paragraph ready event after altering text -



javascript - jQuery height paragraph ready event after altering text -

i'm having issues fetching size of tag after altering containing text. have solution i'm far satisfied with. have (apologies coffeescript, ()=> means function(){})

@textfield = $('<'+tag+'></'+tag+'>') @textfield.html(text).delay(120).queue(()=> @textfield.ready(@ontextready) )

if remove delay, there's no height(), can't utilize window.load either, , @textfield.load seem absolutely nothing.

what thoughts on best practice solve this?

much appreciated

/ a

as far know elements don't have size until added dom. more think there issues size , display none. if interested in size , not in adding element dom suggest play visibility.

var $textfield = $('<div>').text("foo").css({ visibility: "hidden", position: "absolute", display: "block" }).appendto($("body")); var height = $textfield.height(); $textfield.remove(); alert(height);

javascript jquery events load ready

No comments:

Post a Comment