custom attribute works only with element.getAttribute(“attribute”) but not “element.attribute”
问题 I have just noticed, that if I give a custom attribute to an html element, for example: <input type="button" id="my_button" custom_attr="custom_attr_text" value="value_text" /> then i can retrieve it like this: document.getElementById("my_button").getAttribute("custom_attr"); and it will return "custom_attr_text" , but if I do document.getElementById("my_button").custom_attr; then it returns undefined ! I also noticed that with a built in attribute (for example value or id ) both of the above