Code for extracting email address from html?

Kmandapalli
Posted by Kmandapalli under jQuery category on | Points: 40 | Views : 412
var thehtml = $('#' + id + ' p').text(),
emailRegex = /[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/igm;

$('#' + id + ' button.test').live('click', function (e) {
e.preventDefault();
alert(emailRegex.test(thehtml));
});

$('#' + id + ' button.extract').live('click', function (e) {
e.preventDefault();
var resultbox = $('#' + id + ' .extractedemails');
resultbox.empty();
var mEs = thehtml.match(emailRegex),
len = mEs.length;
$.each(mEs, function (index, value) {
resultbox.append(value);
(index !== len - 1) ? resultbox.append(', ') : '';
});
});

Comments or Responses

Login to post response