Reputation: 15006
I'm trying to get all callable phone numbers out of an html-received with a get
:
onload: function (data)
{
data = $.parseHTML(data.response);
var content = $.trim($(data).find('[href^=callto:]').text());
console.log(content)
//var content= $(data).find('.');
}
The data is correct, i successfully found find('.tel')
, a class used in the html.
Upvotes: 2
Views: 7808
Reputation: 540
The colon is a special character in jQuery selectors. You should escape it like this: $(data).find('[href^=callto\\:]')
Upvotes: 1
Reputation: 83
This is how I managed to resolve this problem on my end. :)
/* All phone numbers to href */
var regex = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/;
$('tr td:nth-child(3)').each(function() {
var text = $(this).html();
text = text.replace(regex, "<a href=\"tel:$&\">$&</a>");
$(this).html(text);
});
Upvotes: 1
Reputation: 21708
$('a[href^="tel:"]')
will give you all anchors with a tel:
scheme.
Using your sample code: data.find('a[href^="tel:"]')
Upvotes: 8