我有一个脚本删除记录而不刷新.我还是javascript的新手,并试图学习如何调出这个脚本.这就是我所拥有的.
我的按钮:
<button id="<?php echo $rrr['id']; ?>" class="delbutton" onclick="">Delete</button>
Run Code Online (Sandbox Code Playgroud)
我的Javascript:
<script type="text/javascript" >
$(function() {
$(".delbutton").click(function() {
var del_id = $(this).attr("id");
var info = 'id=' + del_id;
if (confirm("Sure you want to delete this note? This cannot be undone later.")) {
$.ajax({
type : "POST",
url : "delete-note.php", //URL to the delete php script
data : info,
success : function() {
}
});
$(this).parents(".record").animate("fast").animate({
opacity : "hide"
}, "slow");
}
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
我在没有重新加载的情况下进行删除研究时从其他人那里借用了这段代码.通常我会看到一个函数看起来像这样:
function myFunction()
Run Code Online (Sandbox Code Playgroud)
然后我可以使用onclick这样调用它:
onclick="myFunction()"
Run Code Online (Sandbox Code Playgroud)
按照这个脚本的编写方式,我不确定我应该调用什么"函数",或者我是否需要在某处添加名称. …