I tried adding HTML after the element with these simple lines: HTML to copy:
<div class="commentLayout">
<form method="post" action="...">
<textarea cols="10" rows="10" name="taCommentContent">
</textarea>
<input type="hidden" name="newsId" value="">
<button type="submit" class="btn btn-success">speichern</button>
</form>
</div>
And this is the part of JavaScript that adds it:
function createComment (id)
{
var $comment = $(".commentLayout").first().clone();
$comment.removeClass("commentLayout").addClass("commentEdit");
$comment.find("input[name=newsId]").first().val(id);
$(this).after($comment);
}
The following error is displayed in the browser console (with the source map):
jquery2x.min.js:3 Uncaught TypeError: Cannot read property 'createDocumentFragment' of undefined
buildFragment @ jquery2x.min.js:3
domManip @ jquery2x.min.js:3
after @ jquery2x.min.js:
createComment @ frontend.js:716(anonymous function) @ VM219:1
I know what undefined means, but how did this error come about? I do not understand what is wrong here. To clear my question, I call this function from a link, for example:
<a href="javascript:createComment(1);">comment this</a>
source
share