我正在尝试让确认对话框正常工作,但我的 URL 中已经有一个类属性:
<a href="deleteMe.php?key=<?php echo $key; ?> class="load-external" data-target="#right_section">Delete Me</a>
我在下面找到了这个示例,当我使用“确认”类时,它在我上面的链接中起作用,但我需要使用“加载外部”,因为它正在将内容 (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>
有没有什么方法可以内联执行此操作,或者是否有任何其他方法不会与我的 href 链接中必须包含的 class="load-external"冲突??
谢谢
最佳答案
简单的写:
<a href="deleteMe.php?key=<?php echo $key; ?>"
class="confirmation load-external"
data-target="#right_section">Delete Me</a>
您可以在 class
属性字符串中分配任意数量的类。用空格分隔它们。
关于javascript - jQuery 确认对话框 - 类冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30695985/