Can I, a jQuery1.9+ software developer, "deprecate" the use of the
attr() method in my day-by-day work?
As showed in many questions,
- .prop() vs .attr() (main)
- jQuery attr vs. prop, there are a list of props?
- jQuery attr vs prop?
- Migrating jQuery 1.8.3 to 1.9.0 - Replacing deprecated .attr()
- ... etc. ...
there are a lot of confusion about "use attr or use prop?", and, by my (developer's) view point, for all uses of
attr() method, we can use
- backward-compatibility: coding new software not need this;
- performance: John says "Accessing properties through the .attr() method will be slightly slower than accessing them directly through .prop()";
- Change attribute value: all can be changed by the
- Remove attribute: all can be removed by the
- Check HTML attribute values: browser use DOM, all HTML was converted to DOM, and, if DOM affected the
attr(name)method also affected. About "strong type" of prop: it is better than "html string value" (ex. "checked" vs true).
- Check if an attribute was defined in the "HTML original code" (supposing that method
attrin your browser returns undefined if it is not)... Well, we need this in some piece of software? At forms, ".val() method is the recommended jQuery way to get or set the values of form"
- Cross-browser consistency: both (not only attr) are consistent methods. (it is??).
So, at this time (2013), I not see a good reason to use
attr method when developing new jQuery code... But, well, this is, in other words, the question: There are a good reason to use
attr method in my day-by-day tasks?