Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if class is clicked javascript

document.body.onclick = function(e) {
    var clickedEl = window.event ? event.srcElement : e.target;
    while (clickedEl != null) {
        if (clickedEl.className
            && (" " + clickedEl.className + " ").indexOf(" yourclass ") != -1) {
            // do something, e.g.,
            alert("Element with class was clicked");
            return;
        }
        clickedEl = clickedEl.parentNode;
    }
}​
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to hide api key in react 
Javascript :: sort method js 
Javascript :: json validator 
Javascript :: rename column infotable thingworx 
Javascript :: script defer attribute 
Javascript :: suitescript get sublist value 
Javascript :: ~~ in javascript 
Javascript :: change element text innerhtml keeping the elements or tags inside 
Javascript :: Create Your Vue Project 
Javascript :: Regex for number divisible by 5 
Javascript :: jquery connection reset 
Javascript :: sorting algorithms in node.js 
Javascript :: create index mongodb 
Javascript :: destructuring 
Javascript :: javascript Sum of all the factors of a number 
Javascript :: how to use two text fields in one single row react js 
Javascript :: how to convert json to javascript object 
Javascript :: iis express gzip 
Javascript :: create auto increment mongodb mongoose 
Javascript :: upload image in firebase storage react web 
Javascript :: fluent validation email address regex 
Javascript :: yamljs 
Javascript :: how add class to ckeditor image 
Javascript :: node js dependency injection 
Javascript :: jquery daterangepicker using moment 
Javascript :: js reverse 
Javascript :: javascript variables 
Javascript :: javascript Check Map Elements 
Javascript :: HSET in redis 
Javascript :: fibbanacci sequence 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =