Question

JavaScript: Write a function named "insertWord" that that doesn't take any parameters and doesn't return a...

JavaScript:

Write a function named "insertWord" that that doesn't take any parameters and doesn't return a value. This function should find an HTML element with an id of "content" and replace its innerHTML with the string "airplane"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

HTML CONENT:

<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
   <title>Change content</title>
</head>
<body align="center">
   <h1 id="content">This Content Going To Be Changed Now!!!!</h1>
   <button id="click" >Change Content</button>
   <script type="text/javascript" src="content.js"></script>
</body>
</html>

JAVA SCRIPT CONTENT:

function insertWord(){
   //get element using its id.
   //using innerHTML we can change the inner content of the element.
   //here content is replaced with "airplane"
   document.getElementById('content').innerHTML="airplane";
}

//to call the funciton i'm adding one button and its event
//when button was clicked that required function was called.
document.getElementById('click').addEventListener('click',insertWord);

OUTPUT BEFORE BUTTON CLICKED:

OUTPUT AFTER BUTTON CLICKED:

Add a comment
Know the answer?
Add Answer to:
JavaScript: Write a function named "insertWord" that that doesn't take any parameters and doesn't return a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT