At the risk of jumping into a conversation that's a little beyond me,
I'd like to throw in 2 cents as a long time jquery user.

I can follow the arguments being made by those who think attr is
broken.  But I agree with John and company that the attr function does
what it's supposed to do.  It returns the attribute values of DOM
elements.  This argument seems to be a definitional one.  DOM Element !
= HTML source.  Regardless of what the original html source says, once
it's parsed into a DOM it's a living structure with values that
change.  I tend to think of the HTML as the "original" values of DOM
attributes, but subject to change.  jQuery operates on the DOM and as
such, it should return computed values as a matter of course.  This
conflation of DOM and source is probably something that does come up a
lot for beginners and may be part of the learning curve for jQuery.
But I think if the docs make the distinction clear and consistently
return computed values, then it's something everyone can get used to.

With that being said, I can see it also being useful to be able to get
at the original attribute values specified in the source. I don't have
any ideas about this and honestly, I've never had a specific need to
do it.  But perhaps a plugin geared towards this would be better.
$.htmlattr ?

:Marco

On Dec 17, 3:45 pm, Matt <m...@thekrusefamily.com> wrote:
> On Dec 17, 2:26 pm, Leeoniya <leeon...@gmail.com> wrote:
>
> > attr('width') would get the computed
> > width but attr('width', '5') sets the width attribute? there's too
> > much room for ambiguity in my opinion.
>
> Just to clarify, in the case of width the width() method would get
> called in both cases.
>
> So
>   $o.attr('width') == $o.width()
> and
>   $o.attr('width',5) == $o.width(5)
>
> Matt Kruse

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to