2014-02-23 57 views
-1

我有我的<ima>其中包含datadata-commentId,我尝试用一​​个函数来获取数据,但它不工作如何使用的onclick将数据发送到一个功能=“功能myfunction的()”

JS

function getsome(){ 
    var comment_id=$(this).attr('data-commentId'); 
    alert(comment_id); 
} 

HTML

echo '<img onclick="getsome()" class="c_like_icon" data-commentId="'.$reply_id.'" src="img/thumb_icon.png" height="18" width="18">'; 
+0

'$(this).data('commentId');' – hjpotter92

回答