Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dynamic button click in javascript

window.addEventListener('load',function(){
  	const upsellBtn = document.querySelector('.parent-element-class');
        upsellBtn.addEventListener('click',function(e){
			const btnCurrent = e.target.closest('.target-class');
          	if(btnCurrent){
            	console.log( btnCurrent.getAttribute('data-product-id'));
            }
          
      });
  
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: react export 
Javascript :: Saber si un elemento existe en el DOM 
Javascript :: javascript add id to element with class 
Javascript :: code for javascript message box 
Javascript :: check if string is empty 
Javascript :: js random generator 
Javascript :: how to change test colo on js button 
Javascript :: auto scroll to view react-native 
Javascript :: Find the index of an item in the Array 
Javascript :: javascript find matching elements in two arrays 
Javascript :: anonymous function javascript 
Javascript :: Node Folder or file exists 
Javascript :: flutter http get json to map 
Javascript :: Material-ui Accessible icon 
Javascript :: The element.InnerHTML Property 
Javascript :: getting data from an api 
Javascript :: select2 replace options 
Javascript :: js changing selected option by index 
Javascript :: browser detection 
Javascript :: DC League of Super-Pets 
Javascript :: react render twice v18 
Javascript :: Get Keys Of JSON As Array 
Javascript :: import tippy react 
Javascript :: annotation 
Javascript :: expo modal 
Javascript :: kendo jquery grid refresh data 
Javascript :: random unique number generator javascript 
Javascript :: javascript remove last charter stings 
Javascript :: lodash find array of strings 
Javascript :: reactstrap dropdown 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =