Javascript examples for String:replace
Replace text to element string with style
<html> <head> <style> .big{ font-size: 55px; } </style> <script> function chng(){// w ww .j a v a 2 s . c o m var text = document.getElementById('pText').innerHTML; var text2 = text.replace('test','<span class="big">test</span>'); document.getElementById('pText').innerHTML = text2; } </script> </head> <body> <p id="pText"> this is a test </p> <button onclick="chng()">Try it</button> </body> </html>