JQuery – has-attr

Recently I had a problem when i needed to check wheter given DOM element have some attribute. JQuery does not supply us with any function that would have desired behaviour. So I created my own plugin that does that.


The script extends JQuery by adding 2 new functions :

  • hasData
  • hasAttr

Names are pretty straightforward. As example of functionality you can do something like this:


The result will be true.

Package is available on [npm] and [Githbub]. It is also supplied with unit tests which are great reference to see the functionality.

Leave a Reply

Your email address will not be published. Required fields are marked *