I want to capture phone numbers from an HTML document. I have used a pattern but its also selecting numbers that are the part of attributes of tags.
var myArray = $('body').html().match(/([\s()-.])*(0[1-9]|[+][1-9]|[+][+][1-9]|00[1-9])(([\s()-.\/])*[0-9]+)*/g);
The
html()method in jQuery uses theinnerHTMLJavaScript property.The
innerHTMLproperty retrieves the source of an element at runtime.If you need the pure text content of an element (without HTML tags), use the
innerTextandtextContentproperties.Example:
For further details and examples:innerText property, textContent property, innerHTML property.