<script type="text/javascript">
$(document).ready(function()
{
$('table#delTable td a.delete').click(function()
{
if (confirm("Are you sure you want to delete this row?"))
{
var id = $(this).parent().parent().attr('id');
var data = 'id=' id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: "<?php echo site_url('post/pagecreateposts/get_post_by_id')?>/" id,
data: data,
cache: false,
success: function()
{
parent.fadeOut('slow', function() {$(this).remove();});
}
});
}
});
// style the table with alternate colors
// sets specified color for every odd row
$('table#delTable tr:odd').css('background',' #FFFFFF');
});
function goDoSomething(identifier){
alert("data-id:" $(identifier).data('id') ", data-option:" $(identifier).data('option'));
}
</script>
<a class="btn btn-sm btn-danger delete" data-id="1" data-option="1" href="#">ทดสอบ</a>
ใครพอจะทราบวิธีเขียให้เป็นรูปแบบ javascript function บ้าง ขอบคุณครับ