Saturday, 15 March 2014

html - How to wrap any mobile number's into Anchor tag using javascript -


I have an html page where all the data is coming dynamically with some mobile numbers.

Example: & lt; A href = "tel: +91 9999999999" & gt; +91 99 99 99 99 99 & lt; / A & gt;

HTML:

  & lt; P & gt; Phone: +022 23334976 & lt; / P & gt; & Lt; P & gt; Phone: +91 8976817722 & lt; / P & gt; . . . . & Lt; P & gt; & Lt; P & gt; Telephone: & lt; / P & gt; +91 8976817725 & lt; / P & gt;  

Please help me write general JS to handle the above HTML pages.

Try this:

  var body = document.getElementsByTagName (' Body ') [0]; Body.innerHTML = body.innerHTML.replace (/ (?: & Lt; b & gt;) Tele: (?: & Lt; \ / b & gt;) ?? (\ + [0-9] * [ 0-9] *) / Ig, '& lt; a href = "$ 1" & gt; $ 1 & lt; / a & gt;');  

No comments:

Post a Comment