我尝试了很多东西,仍然无法让它运行
<span data-comment-id="123456" class="delete_co">Delete button</span>
<div class="delete_confirm" style="display: none;">
wanna delete?
<form action="" method="post">
<input type="button" value="cancel" class="delete_cc">
<input type="submit" name="comment_delete" value="delete">
</form>
</div>
<script>
$('.delete_co').click(function(){
alert('' + $('.delete_co').data['comment-id']);
$('.delete_confirm').css('display', 'block');
});
$('.delete_cc').click(function(){
$('.delete_confirm').css('display', 'none');
});
</script>
答案 0 :(得分:1)
其alert('' + $('.delete_co').data('comment-id'));
不是alert('' + $('.delete_co').data['comment-id']);
问题是[]