Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Javascript level 1 lesson 2

it tells me to trigger the function doSomething on the onclick and i added the code in the element with (click) within the quotations and the heading changes but it is still telling me to trigger the function what am i doing wrong?
by

1 Answer

ramakrishna1
<!doctype html>
<head>
<title>Javascript with HTML</title>
<script>
/ JS in the head section /
function doSomething() {
document.getElementById("heading").textContent = "New heading";
}
</script>
</head>
<body>
<h1 id="heading">Some Page Heading</h1>
<button onclick="doSomething()">Click me!</button>
</body>
</html>

Login / Signup to Answer the Question.