jquery check if attribute exists
snippet in javascript

jquery check if attribute exists

user4540

var attr = $(this).attr('name');

// For some browsers, `attr` is undefined; for others,
// `attr` is false.  Check for both.
if (typeof attr !== typeof undefined && attr !== false) {
    // ...
}

how to check element has an attribute js

user6446


        
            
        
     let result = element.hasAttribute(name);