Question
The following code has to be ammended in javascript: // TODO: Q1(c)(ii) // Remove the item from local storage by key } // Connect the
The following code has to be ammended in javascript:
// TODO: Q1(c)(ii) // Remove the item from local storage by key }
// Connect the event listener to the button 'click' event deleteButton.addEventListener("click", deleteEntry);
// Add the delete button to the section sectionElement.appendChild(deleteButton);
// Get a reference to the element containing the diary entries var diaryElement = document.querySelector("main");
// Get a reference to the first button section (Add entry/photo) in the diary element var buttonElement = diaryElement.querySelector("section.button");
// Add the section to the page after existing entries, // but before the buttons diaryElement.insertBefore(sectionElement, buttonElement); }
Edit the script where indicated in 'tma03.js' to delete an entry from local storage when it is removed from the DOM. (5 marks) The demonstration application adds a 'Delete entry' button (labelled with an ' X ') to the HTML element containing each entry, which removes that element from DOM when the button is clicked. Add JavaScript code where indicated to also remove the corresponding item from local storage, so that when the application next starts the deleted entry does not reappear. In your solution document, provide your amended JavaScript code. Making and testing this change The code to change is indicated as follows: // TODO: Q1(c)(ii) // Remove the item from local storage by key Read the code and comments above these lines to see what variables exist at this point in the code. Use what you have learned from to complete the code to remove the item from local storage. One way to approach this task is using the JavaScript debugger, as seen in Activity 3 and earlier in Block 2. When this task is complete, you will be able to delete the demonstration entries from the page and see the items representing them disappear from the 'Application' or 'Storage' tab of your browser developer tools - although you may want to keep one for the next section of step (c)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started