0

This is my code. I want to when dblclick in element <li> active event and removeClass when click outside or click into other element.

  initTodoITem: function (todo, lbContent, inputEdit) {
   var item = document.createElement('li');
    item.setAttribute('class', 'todoItem');

    item.addEventListener('dblclick', function (){
      lbContent.classList.add('edit');
      inputEdit.classList.remove('edit');
      inputEdit.classList.add('editing');
    });

    return item;
  },
Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
Trần Hạnh
  • 147
  • 1
  • 10
  • The whole idea is, look for that selector as an ancestor when clicking in the outer containing element (or `document`) and if not, check and/or remove class. It's very simple, actually. – Jared Farrish May 28 '17 at 14:23
  • @Jared Farrish l started learning javascript, I do not know how to write syntax or flow of the command. Please help me make a small example. – Trần Hạnh May 28 '17 at 15:13

0 Answers0