Question: Answer the following set of questions below using the code that is provided. You must use the JavaScript to solve. Part 1) Event Experiment 1:
Answer the following set of questions below using the code that is provided. You must use the JavaScript to solve.
Part 1)
Event Experiment 1: When the button is clicked, use the console log to show the X coordinate position of the mouse on the page. (you will use clientX method)
Part 2)
Event Experiment 2: Look at the code below and imagine that this action event is tied to the button from Part 1. Now, your task is to modify OR add to the code below so that when the button is clicked nothing will happen. (Use the event object to STOP anything from happening. Do not change the tag; just the onclick attribute value)
function test_hashchange(){
if( location.hash === "#experiment2" ){
alert( "You didn't stop the event in Event Experiment 2" );
location.hash= "";
}
}
test_hashchange();
window.addEventListener( "hashchange", test_hashchange, false );
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
