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

Level 1/lesson 2

dosomething and onclick.how to use it
by

2 Answers

sam5epi0l
Use it like this:

<!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>


You learn more about this method in upcoming lessons.
Ranjithqpte7
Bro js level1 lesson3 answer u have please send bro

Login / Signup to Answer the Question.