Replacing things in Jquery | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Replacing things in Jquery

Why would you do: HTML: <p id="demo">Hi </p> JS: $(function() { $("#demo").append("David"); }); //Outputs "Hi David" You could just do <p>Hi David</p> What is a practical application for this?

30th May 2017, 9:33 PM
Zachary Payne
Zachary Payne - avatar
3 Answers
+ 7
sooo many.... just have a look around in tbe code playground most web code use JS this way or another perhaps a simple example i can give is the following code: https://code.sololearn.com/W4o0OK275RS6/?ref=app i use JS to append the word recieved from the server to the HTML page line 16-18 in the JS tab add the word to the page after the user clicks on the button which sends the request once the response from the request returns, the function is called and the word is added to the page dynamically with plain HTML you simply cannot do such things
30th May 2017, 9:47 PM
Burey
Burey - avatar
+ 5
that's what make a web page dynamic instead of being static with ability to change you can interact with the HTML page from JS according to user inputs or actions you cannot do that with HTML alone
30th May 2017, 9:37 PM
Burey
Burey - avatar
0
Do you have an example?
30th May 2017, 9:43 PM
Zachary Payne
Zachary Payne - avatar