为什么我的click()
删除功能在添加图表脚本后不会显示
我的脚本是
<script type="text/javascript">
$(function() {
$(".delete").click(function(){
var element = $(this);
var del_id = element.attr("id");
var info = 'id=' + del_id;
if(confirm("Apakah Anda Yakin Ingin Mengapus Data ini ?")){
$.ajax({
type: "POST",
url: "hapus.php",
data: info,
success: function(){
window.location = 'home.php';
}
});
$(this).parents(".show").animate({ backgroundColor: "#003" }, "slow")
.animate({ opacity: "hide" }, "slow");
}
return false;
});
});
//javascript for ChartJS
var linechart = document.getElementById('line-cpu');
var chart = new Chart(linechart, {
type: 'line',
data: {
labels: <?php echo json_encode($data_tanggal) ?>, // Merubah data tanggal menjadi format JSON
datasets: [{
label: 'Persentase Penggunaan CPU',
data: <?php echo json_encode($data_cpu) ?>,
borderColor: 'rgba(255,99,132,1)',
backgroundColor: 'transparent',
borderWidth: 2
}]
}
});
</script>
对于html代码,我使用的是:
<a class='btn btn-danger delete' href="#" id="<?php echo $srvid; ?>"><i class="halflings-icon trash" title="Hapus Service"></i></a>
JavaScript click()
函数删除在ChartJS的JavaScript添加之前正常运行,你能帮我解决这个问题吗?