tryjsref_replace 在线代码实例
<p>Click the button to replace "Microsoft" with "W3CSchool" in the paragraph below:</p>
<p id="demo">Visit Microsoft!</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var str=document.getElementById("demo").innerHTML;
var n=str.replace("Microsoft","W3CSchool");
document.getElementById("demo").innerHTML=n;
}
</script>