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();
};);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.