Вопрос

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.

Это было полезно?

Решение

You need to use an actual selector, such as a[href^="mailto"]

Другие советы

make like this

 $(document).ready(function() {
              $("a[href^='mailto:']").click(function(){
                          alert('This is some alert text');
                      });
          });
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top