jquery - Append clone() elements with other clone() elements -


i trying append clone() elements between new elements has created javascript so:

var $user_dp = $(this).parent().parent().find('.dp').clone() var $user_name = $(this).parent().parent().find('.alias').clone() var $feed_added = $(this).parent().parent().find('.timeago').clone() var $feed_status =$(this).parent().parent().find('.feed_status').clone()  $('#pop_up_cont #wrap').html('<div>' + $user_dp + $feed_added + '</div><div>' + $feed_status + '</div>') 

im getting [object object][object object][object object] rather elements. link (click on car image)

thank you!

the issue because appending objects string, hence implicitly coerced, resulting in string of [object object]. instead need append() objects individually. try this:

var $container = $(this).parent().parent(); // change closest()  var $user_dp = $container.find('.dp').clone() var $user_name = $container.find('.alias').clone() var $feed_added = $container.find('.timeago').clone() var $feed_status = $container.find('.feed_status').clone()  $('<div />').append($user_dp, $feed_added).appendto('#wrap'); $('<div />').append($feed_status).appendto('#wrap'); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -