Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the following js code so that a button element is clicked to update the m

ID: 3529386 • Letter: M

Question

Modify the following js code so that a button element is clicked to update the message: function updateDuration() { 'use strict'; // Get now: var now = new Date(); // Create the message: var message = 'It has been ' + now.getTime(); message += ' seconds since the epoch. (mouseover to update)'; // Update the page: U.setText('output', message); } // End of updateDuration() function. // Establish functionality on window load: window.onload = function() { 'use strict'; // Create the event listener: U.addEvent(U.$('output'), 'mouseover', updateDuration); // Call the function now: updateDuration(); }; Here is corresponding HTML:

Explanation / Answer

Your HTML is not visible..So i can't test..But u can try the below code..I think it will work..

function updateDuration()

{ 'use strict';

// Get now:

var now = new Date(); // Create the message:

var message = 'It has been ' + now.getTime();

message += ' seconds since the epoch. (mouseover to update)'; // Update the page:

U.setText('output', message); }

// End of updateDuration() function.

// Establish functionality on window load:

document.$ready(function()

{ 'use strict';

// Create the event listener:

U.addEvent(U.$('output'), 'mouseover', updateDuration);

// Call the function now:

updateDuration();

};);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote