Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

How to check Div is disabled onclick in JS

$
0
0

I want to check the div whose class name is swatch-option and which is coming dynamically and there is not only single div with this class there is a lot of div with the same class now I want to check that if one of these div is disable and also click on that div then it shows me a message. let me inform you That I want to do this in javascript not in Jquery. the code I tried is

<script type="text/javascript">
    var e = document.getElementsByClassName("swatch-option");
    e.onClick = MyFunction;

    function MyFunction()
    {
    if (e.disabled == true) {
        alert('working');
    }else{
        alert('not Working');
    }
    }
</script>

I also tried

<script type="text/javascript">

window.onload = function() {
    var e = document.getElementsByClassName("disabled");
    e.onClick = function MyFunction()
    {
    if (e.disabled == true) {
        alert('Working');
    }else{
        alert('not Working');
    }
    }
}
</script>

but still not working

The div on which I want to perform an action

enter image description here the circle I made around the colors is disabled so when I clicked on these colors then it shows a message out of Stock


Viewing all articles
Browse latest Browse all 67411

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>