[jQuery] Re: scrollTop on jQuery object
OK the scrollHeight works, but what with scrollTop? I want to make something like this: obj.scrollTop = obj.scrollHeight; I need scroll down this element on an event. var i = 0; while (json_arr[i].msg) { var json = json_arr[i]; var $msg = $('').addClass(opts.classes.msg).clone(); var $a = $('').addClass(opts.classes.author).clone (); var $t = $('').addClass(opts.classes.time).clone (); var $cont = $('').addClass(opts.classes.cont).clone (); $a .text( json.from ) .moTooltip({ initData : { id : opts.from }}) ; $t .text( json.date ); $cont .text( json.text ); $msg .append($a) .append($t) .append($cont) .appendTo($win.find('.'+opts.classes.msgsCont)); i++; } status('check',2); $top = $win.c(opts.classes.handler); if ( json_arr[0].from != opts.from ) $top.pulse(3,80); var $msgs = $win.c(opts.classes.msgs); var Dmsgs = $msgs[0]; // here is object to scroll // and what there? thx, Arrviasto
[jQuery] Re: scrollTop on jQuery object
There are two ways to get the DOM element out of the jQuery object. Assuming $msgs from your code example, you could get the first message as a DOM element like this: var msg = $msgs.get(0); // or var msg = $msgs[0]; // then get scrollHeight msg.scrollHeight -- Brandon Aaron On Mon, May 18, 2009 at 12:36 PM, Arrviasto wrote: > > Hi! > I have to use scrollTop and scrollHeight properties, but on jQuery > object it returns `undefined`. Is there any method to get this > property from jq object? > > It doesn't matter, but my object looks like this: > > var $win = $(this) // div on my page > var $msgs = $win.find('.msgs'); > > > $msgs.scrollHeight returns 'undefined' > > Thanks, > Arrviasto (Poland) >