I am trying to learn Vanilla JavaScript or pure JS however you look at it. I started off learning jQuery and now I am trying to better my speeds with no framework. I usually can get this with just jQuery but am having a hard time doing this with pure JS.
var a = $('.entry-content'),i;
for (i=0;i<a.length; i++) {
var b = a[i].innerHTML;
var c = document.createElement('div');
var d = c.id = 'reply_bb';
var e = d.innerHTML = 'Reply';
a[i].innerHTML = a[i].appendChild(c);
}
Basically what I would like to do is add an element to the var a element.
<div class="entry-content">
<div>
Words from a poster or whatever would be in side here
</div>
</div>
After javascript =
<div class="entry-content">
<div>
Words from a poster or whatever would be in side here
</div>
<div id="reply_bb">Reply</div>
</div>
Also since this is related. When creating an element dynamically would I use .click
or .on('click',function() {
or how would I go about that? I want it so when the user clicks reply_bb it appends another Element that is already on the page just hidden.