Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Replacing selected text via html tags -->
- <html>
- <body>
- <!-- Button -->
- <!-- Put function name in onClick -->
- <input type="button" value="Click me!" onClick="changeText()" />
- <!-- You must use an id for the javascript to fetch, here we are using a "p" tag -->
- <!-- Put original text in here -->
- <p id="test">This is a test.</p>
- <!-- Code -->
- <script type="text/javascript">
- function changeText(){
- document.getElementById("test").innerHTML = "This is not a test";
- }
- </script>
- <!-- Here, we have successfully changed "This is a test" into "This is not a test" -->
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement