我有以下功能删除一行。我想通过传入#search_result
来重用此功能。如何将变量传递给click事件处理程序?
function row_delete_ajax(event) {
event.preventDefault();
if (confirm(gettext('Are you sure you want to delete this row?'))) {
var url = $(this).attr("href") + "/";
$.post(url, function(result){
$('#search_result').empty();
$('#search_result').append(result);
});
}
};
这是我最初如何绑定功能,但那种卡住如何#search_result
传递给row_delete_ajax
$(document).ready(function(){
$('#search_result').find(".row_delete_ajax").click(row_delete_ajax);
}
这应该对你有帮助 - http://www.quirksmode.org/js/events_access.html –