Wednesday, May 18, 2016

How to replace text in html using javascript?


Ever wonder how to replace the text in html using JavaScript? It's easy!

First, create the html. Please note that you must save the file as .php format.



Next, create the JavaScript File

 


Preview Sample #1
-------------------------------------------------------------------







-------------------------------------------------------------------


Preview Sample #2
-------------------------------------------------------------------
-------------------------------------------------------------------

If you are new to php and JavaScript, here are some of the useful tips that might help you in case you are struggling with the tutorial.

Silly problem that I encountered when doing this.

1) I forget to include the JavaScript in php file.
2) Missing $ sign for JavaScript.
3) Using inappropriate variable name such as var.



EmoticonEmoticon