Sprint 1 – deleteListItem function

Delete List Item (on-click) event handler

When the user clicks Delete button this function is invoked to effect deletion of the selected (highlighted) Task.

function deleteListItem() {
  var objHighlightedItem = document.querySelector('.highlighted');

  if (!!objHighlightedItem) {
    if (confirm("Are you sure you want to remove this item?",false)) {
      objHighlightedItem.parentNode.removeChild(objHighlightedItem);
    }
  }
}
  1. The selected (highlighted) task is first located in the Task list.
  2. The User is prompted to confirm the requested action – we would not want to delete by mistake.
  3. If confirmed, the Task is removed from the list.

Return to the Sprint One section.
Return to the main article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s