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

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -