On Jun 19, 1:21 pm, Karl Swedberg <k...@englishrules.com> wrote:
> Here, .attr() is a bit of a misnomer, because it's really looking at  
> DOM properties, not (x)HTML attributes. I'm pretty sure either one  
> works, but I use .attr('checked', true)

Indeed, the code internally sets the DOM attribute rather than calling
setAttribute().
It's been this way for a long time, and it's a favorite criticism of
jQuery from some on comp.lang.javascript.
Will it ever be fixed?

> Actually, when I can get away with avoiding .attr() I usually do. For  
> example, I would do:
> this.checked = true;

jQuery should really have .prop() which would work like attr() usually
intends to, but deal only with DOM properties rather than trying to
manipulate actual attributes. Script authors usually want to deal with
properties anyway, and attr() only makes it confusing.

Matt Kruse

Reply via email to