There is such a piece of code:

element.closest('.comment').after(commentItem) 

It adds some commentItem content (contains HTML) after element. Content is a div block, how to add a new class to this created block?

  • one
    > commentItem (contains HTML) In this html and add the class attribute. - alvoro

1 answer 1

 element.closest('.comment').after($('<div>The test</div>').addClass(class)) 

or

 $('<div>The test</div>').insertAfter(element.closest('.comment')).addClass(class)