JSFiddle - React, Tailwind, and code Playground

by salt

HTML

<div class="box" data-lat="11" data-lng="22">hello</div>

JavaScript

(function ($) {
  $.fn.hasAttr = function (attrName) {
		return (this.filter(function() {
			if ( typeof $(this).attr(attrName) !== undefined ) {
				// note: this test does not distinguish between an element with no 'attrName' attribute
				// or an element with an 'attrName' equal to an empty string, both cases return false
				return true;
			}
			return false;
		}));
	};
  
  console.log($(".box")[0].hasAttribute("data-lat"));
    
  console.log($(".box").hasAttr("data-lat"));
}(jQuery));