Here is our Digital Chalkboard exercise from Wednesday.
// Tasks // 1. Create the framework for a function called congrats() that takes no parameters; // 2. Target the element for use in the script. // 3. Use a JS method to change the text node of the element. // 4. Deliver the script to the client and assign the function to the button. function congrats() { document.getElementById("subtitle").innerHTML = "Congratulations!"; }
Here’s how to invoke the JavaScript function using an onclick event:
<input type="button" value="Show Image" class="btn btn-primary btn-lg" onclick="congrats()">