html - cant get custom data attributes value in jquery -


<input type="submit" value="+" data-commentid="{{ $comment->id }}" data-postid="{{ $post->id }}" data-likes="{{ $comment->likes }}" class="likebtn increment"> jquery like

$('.likebtn').on('click', function(e) { e.preventdefault(); // commentidとpostidもhtmlから取ってくる commentid = parseint($('this').attr('data-commentid')); console.log(commentid); postid = parseint($('this').attr('data-postid')); console.log(postid); likes = parseint($('this').attr('data-likes')); console.log(data-likes); like_function(commentid, postid, likes, $('this')); }); 

in console see these variables returns nan. wrong?

do not use quotations around this.

$(this) notice no quotations.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -