gpt4 book ai didi

javascript - fancybox 输入在

转载 作者:行者123 更新时间:2023-12-02 19:45:04 26 4
gpt4 key购买 nike

此示例显示了我正在尝试执行的操作:http://jsfiddle.net/Dqjvy/

我希望它能够工作,以便当您单击输入删除文件时,无需加载 fancybox 即可工作。

如何在单击输入时阻止 fancybox 加载?这也会阻止表单提交,因为 fancybox 已加载?

HTML:

<a class="fancybox" rel="fancybox" href="http://farm7.staticflickr.com/6048/6370091853_fa920568e4_b.jpg" title="Tree and Bench, Newlands Corner (craig.denford)">
<img src="http://farm7.staticflickr.com/6048/6370091853_fa920568e4_m.jpg" alt="">
<input type="button" onClick="return confirm('Are you sure you want to delete this file?');" value="Delete" name="delete_file" />
</a>

<a class="fancybox" rel="fancybox" href="http://farm7.staticflickr.com/6032/6370797521_74a61aec56_b.jpg" title="Brighton West Pier (George-Edwards)">
<img src="http://farm7.staticflickr.com/6032/6370797521_74a61aec56_m.jpg" alt="">
<input type="button" onClick="return confirm('Are you sure you want to delete this file?');" value="Delete" name="delete_file" />
</a>

<a class="fancybox" rel="fancybox" href="http://farm7.staticflickr.com/6182/6059490424_451d8d75b8_b.jpg" title="Romantic sunset. EXPLORE (Grbavica)">
<img src="http://farm7.staticflickr.com/6182/6059490424_451d8d75b8_m.jpg" alt="">
<input type="button" onClick="return confirm('Are you sure you want to delete this file?');" value="Delete" name="delete_file" />
</a>

<a class="fancybox" rel="fancybox" href="http://farm7.staticflickr.com/6106/6347065961_bb73745e70_b.jpg" title="Fog (giulio bassi q°ן°p)">
<img src="http://farm7.staticflickr.com/6106/6347065961_bb73745e70_m.jpg" alt="">
<input type="button" onClick="return confirm('Are you sure you want to delete this file?');" value="Delete" name="delete_file" />
</a>

JavaScript:

$('.fancybox').fancybox();

/*$('.fancybox').click(function(e) {
e.preventDefault();
$(this).fancybox();
});*/

最佳答案

将按钮的 onClick 属性替换为 class 属性,并在 js 中添加此 click 处理程序:

HTML:

<input class="delete" type="button" value="Delete" name="delete_file" />

JS:

$('.delete').click(function() {
if (confirm('Are you sure you want to delete this file?')) {
// TODO: delete file
alert('deleted');
}
return false;
});

另请参阅this example .

关于javascript - fancybox 输入在 <a> 内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9963811/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com