In: Computer Science
Q: Provide JavaScript code to change the font family of the first h1 heading in the document to Arial?
font.html
<!DOCTYPE html>
<html>
<head>
<title>font</title>
<script type="text/javascript">
function fun(argument) {
// body...
document.getElementById("first").style.fontFamily =
"Arial"; //get heading by id and set the font family
style to Arial
//alert("Hello");
}
</script>
</head>
<body>
<h1 id="first">Heading 1</h1>
<h1 id="second">Heading 2</h1>
<button onclick="fun()">click to change
font</button>
</body>
</html>
OUTPUT:
if you have any doubts please COMMENT....
If you understand the answer please give THUMBS UP...