Here is a one-liner for you.
Replace $jQueryObject
with your jQuery object. i.e $('div')
.
Object.values($jQueryObject.get(0).attributes).map(attr => console.log(`${attr.name + ' : ' + attr.value}`));
Replace $domElement
with your HTML DOM selector. i.e document.getElementById('demo')
.
Object.values($domElement.attributes).map(attr => console.log(`${attr.name + ' : ' + attr.value}`));
Cheers!!