我有两个链接编辑和删除按钮。我想要的是将编辑的确认消息分开删除。当我单击编辑按钮时,该消息用于编辑按钮,如果删除按钮则显示另一条消息。我怎么能这样做?
<script>
jQuery(function ($) {
$('a.button.edit, a.button.remove').click(function () {
if ($('input[name="checkbox[]"]:checked').length == 0) {
return;
}
if(!confirm('Do you want to continue?')){
return
}
var frm = document.myform;
if ($(this).hasClass('edit')) {
frm.action = 'editpr.php';
}
if ($(this).hasClass('remove')) {}
frm.submit();
})
})
</script>
<a class="button edit" style="cursor:pointer;"><span><b>Edit Purchase Request</b></span></a>
<a class="button remove" style="cursor:pointer;" name="remove"><span><b>Remove Purchase Request</b></span></a>
答案 0 :(得分:0)
您可以这样做,检查课程并相应地确认消息
$('a.button.edit, a.button.remove').click(function () {
if ($('input[name="checkbox[]"]:checked').length == 0) {
return;
}
if($(this).hasClass('edit')) {
if(!confirm('Do you want to edit?')){
return
}
else {
if(!confirm('Do you want to remove?')){
return
}
}
<强> Demo 强>
答案 1 :(得分:0)
<script>
jQuery(function ($) {
var triggerClick = function(str) {
$('a.button.' + str).click(function () {
if ($('input[name="checkbox[]"]:checked').length == 0) {
return;
}
if(!confirm('Do you want to continue?')){
return;
}
var frm = document.myform;
frm.action = str + '.php';
frm.submit();
});
};
triggerClick('edit');
triggerClick('remove');
})
</script>