Monday 10 March 2014

Replacing Text with JavaScript


This text will replace by pressing below button




Code is below:


<div id="check"> <!-- A new div is assign for replacing text -->
This text will replace by pressing below button</div>
<br />
<script>
function myfunction()
{
 document.getElementById("check").innerHTML="Replica Text Through Java Script";
// get element by id which is "check" and new text will be added in div section through innerHTML
 }
</script><br />
<button onclick="myfunction()" type="button">Replace Text</button><br />
<!-- by clicking button it calls function name "myfunction" and function will rewrite text in div section -->
<div>


No comments:

Post a Comment