I want to attach data attribute to element. My code is
$('<a>', {
class: 'like-comment
comment-like-color
comment_main_id_' + response.id,
text: '',
href: 'javascript:;',
}).appendTo(commentBody)
.append($('<i>', {class: 'fa fa-thumbs-up'}));
My HTML data generated is like
<a class="like-comment comment-like-color
comment_main_id_{{$comment['id']}}" href="javascript:
data-like-comment-id=" {{$comment[ 'id']}} ";">
<i class="fa fa-thumbs-up" aria-hidden="true"></i>
</a>
There's a data (data-like-comment-id) attribute, which I want to create using jQuery. Could someone please help me with it.