用JQuery寻找页面所有的电子邮箱地址
下面的例子展示了如何使用JQuery找到所有的电子邮箱地址。
?
<!DOCTYPE html><html><head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function(){ var emails = $("a[href^='mailto:']"); var idx; var len = emails.length; var str = "Found the following `mailto` links:<ul>"; for (idx = 0; idx < len; idx++) { str += "<li>" + emails[idx] + "</li>"; } str += "</ul>" $('p#debug').html(str); }); </script></head><body> <a href="http://cfexamples.com/">Go to ColdFusionExamples.com</a> <a href="mailto:jane@doe.com">email Jane Doe</a> <a href="mailto:user@domain.org">email User</a> <p>The quick brown fox jumps over the lazy dog</p> <hr/> <p id="debug"></p></body></html>
?
源代码:
findmailto.zip
?
?
?
?