Hi Again,
You (John Resig) say that both attributes and properties do essentially the
same thing:
"having both a .attr() and a .prop() method is redundant, as they'd
both end up doing, essentially, the same thing"
Now I know that in theory this should be correct - but on a fair few
occasions I've found that some attributes only seem to have the appropriate
HTML/DOM effect if set using setAttribute and in doing so can only be
retrieved using getAttribute - whereas directly assigned properties exibit a
different behaviour (most notably not be accessible through getAttribute)
Now oddly this behaviour isn't experienced when setting element ids, and we
also know that to set a class you use .className - however in other cases
you'll find that setting properties directly has a different effect to
setting them through setAttribute. I can't say for certain whether this is
just a weird implementation in some browsers or default behaviour since I
usually have only come across when something hasn't worked so I pretty much
just switch the method I'm using and it works.
I apologise for my lack of detail - if I get time I will run through some
experiements and tell you my findings (I'll checkout the svn jquery too and
see how it behaves)
If anyone else has noted this behaviour please jump in - it'd be good to
know I'm not just crazy lol.
Still loving jquery - so far managed to switch 2 members of the team at work
including the head developer - I'd like to take some credit but really it
was just the excellent functionality that won them over. Well done John -
you're a hero (not forgetting the other contibuters too)
------------------------------------------------
Date: Fri, 4 Aug 2006 18:50:15 -0400
From: "John Resig" <
jeresig@gmail.com>
Subject: Re: [jQuery] $('').attr('', '') - why no direct method to
get/set html attributes?
To: "jQuery Discussion." <
discuss@jquery.com>
Message-ID:
<
730bab940608041550r1907bf7bg8072d46165e6821@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed