Question: I used to use the following to know if a clicked item was a checkbox:

```
if ($(e.target).className === 'checkbox') {}

```

After upgrading to the latest version of jQuery this now returns undefined for Chrome, Safari and Firefox.

What is the best way to determine if a click happened on a checkbox?

Thanks

Answer: 
Try using `.is` function and `:checkbox` selector

```
if ($(e.target).is(':checkbox')) {
   //it is a checkbox
}

```

**DEMO:** <http://jsfiddle.net/a5SbG/1/>

or You can try

```
if (e.target.type == 'checkbox') { 
  //It is a checkbox
}

```

**DEMO:** <http://jsfiddle.net/a5SbG/>
This seems to work for me:

```
window.addEventListener('load', function () {

    function onClick() {
        if (this.tagName.toUpperCase() === 'INPUT' && this.type.toUpperCase() === 'CHECKBOX') {
            console.log([this.tagName, this.type])
        } else {
            console.log("HTML Element has Wrong tag or type");
        }
    };

    document.getElementById("myCheckBox").addEventListener('click', onClick);
    document.getElementById("myButton").addEventListener('click', onClick);
});

```

HTML:

```
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <label><input id="myCheckBox" type="checkbox" />Click Me!</label>
    <input type="button" id="myButton" value="Click Me!" />
    <script type="text/javascript" src="detectElementType.js"></script>
</body>
</html>

```

See it in action here (hit F12 in Chrome to see console, or open FireBug console, etc.):

<http://www.sanbarcomputing.com/flat/forumPosts/detectElementType/detectElementType.html>

addEventListener() is not supported by all browsers (new in ECMAScript 5) but has advantages. See an article on event handlers here:

<http://www.javascripter.net/faq/addeventlistenerattachevent.htm>