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?
3 Respostas
+ 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
+ 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
0
Do you have an example?