adding newly created dom elements to an empty jQuery object

Posted by taber on Stack Overflow See other posts from Stack Overflow or by taber
Published on 2010-05-14T05:29:02Z Indexed on 2010/05/14 5:34 UTC
Read the original article Hit count: 308

Filed under:
|
|
|

Why doesn't this work in jQuery 1.4.2?


var $list = $([]);
for(var i=0; i<50; i++) {
    $list.add( $('<div/>', { id: 'jake', class: 'test' }).data('test', { hi: 'hello' }) );
}
alert($list.size()); // 0

Thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript