我有很多这样的href:
<a class="download " target="_self" href="../res/DOC140416-1.pdf" download="DOC140416-1.pdf
其他人则不以pdf文档为目标。
有没有一种方法可以仅针对以pdf文件为目标的href调用js函数?
我正在寻找一个将从index.html加载的js函数,该函数在整个“站点”中都是持久的(适用于混合应用程序)。
谢谢你。
使用jQuery,您可以选择所有指向PDF文件的链接,并在单击这些链接时执行JS函数。
$('A[href$=\\.pdf]').click(function() {
alert('here'); //Do whatever you want
return false; //Returning false to skip link normal behavior
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句