Forum Moderators: open
// this will show EVERY attribute for an element where ele is the ID of the element
var css_obj = getComputedStyle(document.getElementById(ele));
for (i = 0; i < css_obj.length; i++)
console.log(css_obj[i] + ': ' + css_obj.getPropertyValue(css_obj[i])); // this shows all of the styles that are set for the element
const node = document.getElementById(ele);
const attributeNodeArray = [...node.attributes];
const attrs = attributeNodeArray.reduce((attrs, attribute) => {
attrs[attribute.name] = attribute.value;
return attrs;
}, {});
console.log(attrs);