I once saw a text about Jquery stating that in Jquery some properties have different names. I think it was the value property that is accessed in Jquery as val or something like that. Does JQuery do this a lot? Is a common practice of Jquery to change properties names?
Share
jQuery does not change any property names.
jQuery implements it’s own methods on jQuery objects. Those are completely separate from DOM properties or DOM methods.
For example, you can retrieve the value of any input control from a jQuery object using the
.val()method. Internally, the.val()method on the jQuery object accesses the contents of the DOM object (perhaps using the.valueproperty), but it is not replacing that DOM property in any way. It is still there is you choose to use it instead.Similarly, jQuery has a
.html()method that returns theinnerHTMLof an object. Again, this is jQuery method on a jQuery object and does not replace the DOM propertyinnerHTMLin any way.Here are some code examples to illustrate:
Using plain javascript:
Using jQuery:
Notice that both the jQuery ways are method calls, not properties.
Even when using jQuery objects, you could get the DOM object out of the jQuery object using the
.get(n)method and use the DOM property, though there usually isn’t a reason to do so: