How to append html elements to added elements?

53 views
Skip to first unread message

brendan

unread,
Jun 24, 2014, 5:29:20 AM6/24/14
to mutation-sum...@googlegroups.com

I'm using Mutation Summary library to observe when a particular type of elements have been added and then append each of them with my html element:

var observer = new MutationSummary({
      callback: theNextPageLoaded,
      queries: [{
           element: "li.sweet"
      }]
});

function theNextPageLoaded(summaries) {
    var sc = summaries[0],
    sc_length = sc.added.length,
    btn = $('<button>', {
          class: 'my_btn',
          text: 'Please work!'
        });

    sc.added.forEach(function(newEl) {
      newEl.appendChild(btn);
      console.log(typeof(newEl));  //newEl's type is 'object'
    });
}

Code above is not working. I'm not sure I can even use appendChild on an object. Any help would be appreaciated!

brendan

unread,
Jun 24, 2014, 7:11:25 AM6/24/14
to mutation-sum...@googlegroups.com
Sorted. btn is a jquery object. so i had to convert .get(0) to get dom format.


Rafael Weinstein

unread,
Jun 24, 2014, 1:09:34 PM6/24/14
to mutation-sum...@googlegroups.com
Hi Brendan,

Can you please create the smallest possible jsbin (or similar) which reproduces the problem?


On Tue, Jun 24, 2014 at 4:11 AM, brendan <kwe...@gmail.com> wrote:
Sorted. btn is a jquery object. so i had to convert .get(0) to get dom format.


--
You received this message because you are subscribed to the Google Groups "mutation-summary-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-d...@googlegroups.com.
To post to this group, send email to mutation-sum...@googlegroups.com.
Visit this group at http://groups.google.com/group/mutation-summary-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages