troubleshooting Question

Detecting when button is clicked using Javascript based off of custom attribute name?

Avatar of 894359
894359Flag for United States of America asked on
JavaScriptWeb Development* HTML 5
2 Comments1 Solution84 ViewsLast Modified:
How would I detect when this button
<button class="btn btn-mobile btn-page-next btn-next-residency" data-name="btn-page-next" type="button">CONTINUE<i class="icon-arrow-thin-right"></i><i class="spinner"></i></button>
is clicked? I tried :
    function _dtmCheckContinue(){
        document.body.addEventListener('click', function(event) { 
	      if((event.target.dataset)&&(event.target.type == "button")){ 
             if(event.target.dataset.value == "btn-grp-next"){
             console.log("<=====> CONTINUE BUTTON CLICKED");
             }
          }
      
        });
    }
I can never get into the if statement on line 4 so obviously there is an issue there.

Thanks!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros