$.fn.hasAttr = function(name) { return this.attr(name) !== undefined; }; if(!$(dfpStoFullId).hasAttr('data-google-query-id')){ HideSto(); $(stoEl).hide(); console.log('sto display none'); }