OBSTRUM
Technology Blog. Covering useful tips, tutorials, solutions and news.
Menu
Info Zone
News
Learning Zone
Tutorial
Tips & Solutions
PHP
Javacript
VPS Ubuntu
Laravel
Extra
Home
Javascript
How to replace text in html using javascript?
Wednesday, May 18, 2016
How to replace text in html using javascript?
Writer
m
Published
Wednesday, May 18, 2016
Tags
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.
Click the button and I will transform
Next, create the JavaScript File
function transform_word() { transform_word = "
You Did IT!!!
"; $("#words").html(transform_word); }
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.
m
Next Post
Previous Post
Emoticon
Emoticon
Subscribe to:
Post Comments (Atom)
EmoticonEmoticon