After reading (the interesting) .prop() vs .attr() and jQuery Performance : attributes doubt arise in my mind about what is better to use: .prop() or .val() ? I want to set
Your charts are indicating that prop()
is better than val()
in terms of performance.
val()
could be internally using the same logic of prop()
along with some additional code statements for completing the actual operation(Ex: setting value), that additional code of val()
might lead to little low performance than prop()
.
It would be nice to use val()
for setting a value for an element perhaps that is what this function is meant for, in general it's preferred to go with the operation specific functions instead of using the generic ones.
In your case, if you don't want to loose even a slight variation in performance then go with prop()
itself.