has-class

Check if an element has the given class.

Usage no npm install needed!

<script type="module">
  import hasClass from 'https://cdn.skypack.dev/has-class';
</script>

README

has-class

Check if an element has the given class.

Install

$ npm install --save has-class

Usage

var hasClass = require('has-class');
var el = document.querySelector('div');

hasClass(el, 'foo');
//=> true

Browser API

hasClass(element, className)

element

Required
Type: HTML DOM element

Element to test with.

className

Required
Type: string

Class name to test against.

Related

License

MIT © Andreas Gillström