开发者

Catch clicks on file links (as opposed to page links) in jquery?

开发者 https://www.devze.com 2023-01-09 16:19 出处:网络
I want to add an event to my users clicking on file links (as opposed to links to i开发者_运维知识库nternal or external pages).Is there a simple way to just get file linkswith a jquery selector?Or, do

I want to add an event to my users clicking on file links (as opposed to links to i开发者_运维知识库nternal or external pages). Is there a simple way to just get file links with a jquery selector? Or, do you think it's better to put a class on my file links and just select on the basis of that class?

thanks, max


Use $ to get links having file extension:

$('a[href$=".pdf"]')

You can replace the .pdf with whatever file extension you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号