Question

Write the necessary Javascript code to change color of the text in a paragraph with an...

Write the necessary Javascript code to change color of the text in a paragraph with an id of "paragraph 1" to red when the user types in a field with an ID of "my field."

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

Coding

<!DOCTYPE html>
<html>
<head>
<Title>Simple Color change </Title>
</head>
<body>
<p id="paragraph1">Here is the Hello World!</p><!-- Here is the Paragraph with paragraph1 id -->
<button id="myfield" onclick="changeColor()" >Click me</button><!-- Here is the button myfield -->
<script>
function changeColor() {
document.getElementById("paragraph1").style.color = "Red";//change property here
}
</script>

</body>
</html>

output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
Write the necessary Javascript code to change color of the text in a paragraph with an...
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