Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

addEventListener call only once

var list = document.getElementsByTagName('ul')[0]

list.addEventListener('click', function(e){
  var el = e.target
  // walk up the tree until we find a LI item
  while (el && el.tagName !== 'LI') {
     el = el.parentNode
  }
  console.log('item clicked', el)
},{ once: true }) // when we use once as true, it will never call again
Comment

PREVIOUS NEXT
Code Example
Javascript :: antd modal hide ok button 
Javascript :: react-lottie yarn 
Javascript :: arrondi js 
Javascript :: sort object dictionary javscript 
Javascript :: get object key from value javascript 
Javascript :: javascript copy some properties from one object to another 
Javascript :: jqurey text contains selector 
Javascript :: js convert to fraction 
Javascript :: convert file to blob javascript 
Javascript :: js add class 
Javascript :: example of pre increment in js 
Javascript :: run jest on single file 
Javascript :: lodash sumby 
Javascript :: react yup password with number string and uppercase 
Javascript :: iframe reload parent 
Javascript :: session undefined nextauth 
Javascript :: javascript last character 
Javascript :: An external JavaScript cannot contain the <script tag 
Javascript :: mongodb sort query 
Javascript :: how to append value to input field using jquery 
Javascript :: console.log clear screen 
Javascript :: $ is not a function 
Javascript :: regexp object javascript 
Javascript :: array from set javascript 
Javascript :: javascript disable form 
Javascript :: set js 
Javascript :: notice before reload js 
Javascript :: exclude file types from formater vscode 
Javascript :: localstorage javascript array 
Javascript :: javascript sort array of objects by property alphabetically 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =