console.log(document.querySelector("#this-input").getAttribute("type"));// t // attributeconsole.log(document.querySelector("#this-input").type);// text // property
console.log(document.querySelector("#this-input").getAttribute("value"));// testconsole.log(document.querySelector("#this-input").value);// tconsole.log(document.querySelector("#this-input").defaultValue);// test
console.log(document.querySelector("#another-input").customize);// undefinedconsole.log(document.querySelector("#another-input").getAttribute("customize"));// test
<!DOCTYPEhtml><html><head><title>Attribute Property</title></head><body><inputid="this-input"type="t"value="test"/><inputid="another-input"type="type"customize="test"/></body><scripttype="text/javascript"> console.log(document.querySelector("#this-input").type);// text console.log(document.querySelector("#this-input").getAttribute("type"));// t console.log(document.querySelector("#another-input").customize);// undefined console.log(document.querySelector("#another-input").getAttribute("customize"));// test</script></html>