On Wed, Jan 19, 2011 at 2:29 AM, RobG <[email protected]> wrote:

>
> The dynamic nature of modern web pages is inconsistent with that
> principle. DOM properties are designed to be dynamic and used with
> scripts, they are more reliable and consistent across browsers.
> Therefore properties should be used unless there is a very specific
> need to use an attribute.
>

Markup confuses people.. I even wrote about it this weekend:
http://blog.millermedeiros.com/2011/01/why-most-js-devs-dont-understand-oop/



> > >> PS: I also tried to remove the attribute using jQuery method
> > >> ".removeAttr()" cited in a previous posts but it doesn't seem to
> > >> remove the HTML attribute from the element :)
> >
> > > really good explanation Diego.. and I also confirmed that on Firefox
> > > setting/removing the attribute without jQuery (using
> > > setAttribute/getAttribute)
>
> Using setAttribute to remove attributes is not recommended, the
> removeAttribute method should be used for that. Note that
> removeAttribute doesn't remove any attribute that has a default value,
> the attribute is just set back to its default.
>
>
Yeah, I used removeAttribute to remove it, just forgot to include it inside
the parenthesis.. sorry.



> >> .. adding a new method called
> > > `.prop()` and avoid overloading the `.attr()` method would be probably
> a
> > > better approach (in my opinion).
>
> No, that would be just as bad. I don't see the need for a method to
> access a property that can be read directly. Just forget about
> attributes, use properties only. And only use standard properties for
> DOM objects.
>

jQuery users like chaining..


PS: really good discussion so far.. thanks

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to