Which is the different between property and attribute?

A property is in the DOM; an attribute is in the HTML that is parsed into the DOM.

HTML Attributes


<body onload="foo()">

DOM Properties


document.body.onload = foo;

Using jQuery

If we have:

<!-- HTML -->
<input class-gns="brand">
// jQuery
$("input").attr("data-gns"); // return "brand"
$("input").prop("data-gns"); // return "undefined" because it is not in the DOM.
// It's trying to get [HTMLInputElement].data-gns

See a real example: