我的问题是,当<a>标记没有链接时,如何在单击链接时停止下载?
例如,:我的链接在下面
<a href="javascript:void(0);" download>download</a>
所以当我点击下面的链接下载一个void(0)文件
但是当<a>标签没有链接和href=javascript:void(0)时,我想停止下载
发布于 2017-10-10 13:18:52
是的,我已经解决了<?php condition的问题
如果变量没有价值,则比创建不带<a>选项的download标记更有价值,如果变量有值,则通过下载创建<a>标记
发布于 2017-09-19 11:01:53
编写一个,单击事件处理程序并防止默认事件,如下所示,
$('a#id-of-it').on('click', function(event) {
// Do whatever you want
event.preventDefault();
})这个html看起来像,
<a href="#" id="id-of-it">Download</a>发布于 2017-09-19 10:58:29
只需从标签中删除下载attr即可
<a href="javascript:void(0);" class="classname">download</a>也可以使用jquery。
$('tag.classname').on('click', function(e) {
e.preventDefault();
//this stop default prevent or action
or you can use
e.stopPropagation();
})
$('a.demo').click(function(e) {
e.preventDefault();
//this stop default prevent or action
//or you can use
e.stopPropagation();
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="javascript:void(0);" class="demo" download>download</a>
或使用javascript
document.getElementById("demo").addEventListener("click", function(e){
e.preventDefault()
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="javascript:void(0);" id="demo" download>download</a>
https://stackoverflow.com/questions/46298655
复制相似问题