Skip to content
Programming Questions · Q11

Q.Write the JavaScript and HTML needed so that clicking a button changes the text of a paragraph (id="msg") to "Welcome!".

Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
92% · 11/12 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Interactivity comes from an event (the click) triggering an event handler (our function), which changes the page through the DOM.

<p id="msg">Hello</p>
<button onclick="showWelcome()">Click</button>

<script>
  function showWelcome() {
    document.getElementById("msg").innerHTML = "Welcome!";
  }
</script>
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.