use the sample html file below with a submit button to modify the style of the p
ID: 3784319 • Letter: U
Question
use the sample html file below with a submit button to modify the style of the paragraph text through JavaScript code. By clicking on the button, the font, the font size, and the color of the paragraph text will be changed.
<!DOCTYPE html>
· <html>
· <head>
· <meta charset=utf-8 />
· <title>Change Paragraph Text</title>
· </head>
· <body>
· <p id ='text'>I’m going to change this text, I hope.</p>
· <div>
· <button id="jschange"
· onclick="js_style()">Style</button>
· </div>
· </body>
· </html>
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script type="text/javascript">
function change_para_style()
{
text.style.fontSize = "20pt";
text.style.fontFamily = "Comic Sans MS";
text.style.color = "blue";
}
</script>
<title>Change Paragraph Text</title>
</head>
<body>
<p id ='text'>I'm going to change this text, I hope.</p>
<div>
<button id="jschange"
onclick="change_para_style()">Style</button>
</div>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.