What is the function of JavaScript snippets ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the function of JavaScript snippets ?

<head><script>function myFunction(){document.getElementById("demo").innerHTML="Paragraph changed";}</script></head>

24th Apr 2017, 12:49 PM
Vasanth Kumar
Vasanth Kumar - avatar
2 Answers
0
The above code snippet just change the paragraph content to "Paragraph changed". explanation: myFunction() is a function which performs this operation. It contains inbuild functions: 1) getElementById() which has a parameter demo. It checks all element in a HTML DOM(Document Object Model) (basically a tree which has all html elements in your webpage as nodes) & selects element with id "demo". 2) innerHTML is a JavaScript construct which is used to change the contents of the HTML elements. Happy Coding....😊
24th Apr 2017, 5:18 PM
Sandip Bhambre (Sandy)
Sandip Bhambre (Sandy) - avatar
0
thank you
24th Apr 2017, 5:27 PM
Vasanth Kumar
Vasanth Kumar - avatar