Is there a way with javascript to automatically have the page look for any mailto links and then have it fire off an alert when a user clicks on the mailto link?
I currently have this:
HTML:
<a href="mailto:nachomomma@notyourdomain.com">Email Link</a>
Javascript:
$(document).on('click','mailto',
function() {
alert('This is some alert text');
});
But that doesn't seem to work. Not too sure if I am going about this the correct way or if it's even possible.
您需要使用实际的选择器,例如a[href^="mailto"]
make like this
$(document).ready(function() {
$("a[href^='mailto:']").click(function(){
alert('This is some alert text');
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.