jQuery确认对话框 - 冲突类

时间:2015-06-07 16:42:11

标签: javascript php jquery html5 function

我试图让确认对话框生效,但我的网址中已经有了一个class属性:

<a href="deleteMe.php?key=<?php echo $key; ?> class="load-external" data-target="#right_section">Delete Me</a>

我在下面找到了这个示例,当我使用Class&#34;确认&#34;它适用于我上面的链接,但我需要使用&#34; load-external&#34;因为它将内容(deleteMe.php)加载回相同的DIV,而不是加入一个全新的页面。

<a href="deleteMe.php?key=22" class="confirmation">Link</a>

<script type="text/javascript">
$('.confirmation').on('click', function () {
    return confirm('Are you sure you want to Delete this record?');
});
</script>

有没有办法以内联或任何其他方式执行此操作,因此它不会与类冲突=&#34; load-external&#34;我必须在我的href链接??

由于

2 个答案:

答案 0 :(得分:1)

您可以根据需要创建多个课程。例如:

<a href="deleteMe.php?key=22" class="confirmation load-external">Link</a>

您也可以根据需要选择多个元素,因此可以:

$('.confirmation, .load-external').on('click', function () {
    return confirm('Are you sure you want to Delete this record?');
});

答案 1 :(得分:1)

简单地写:

<a href="deleteMe.php?key=<?php echo $key; ?>" 
 class="confirmation load-external" 
 data-target="#right_section">Delete Me</a>

您可以在class属性字符串中指定任意数量的类。用空白分开。

相关问题