<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Querying it jQuery way: getElementsByClass</title>
	<atom:link href="http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/feed/" rel="self" type="application/rss+xml" />
	<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/</link>
	<description></description>
	<lastBuildDate>Tue, 11 Aug 2009 16:12:23 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: abhishekhurana</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-128</link>
		<dc:creator>abhishekhurana</dc:creator>
		<pubDate>Mon, 06 Oct 2008 06:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-128</guid>
		<description>jQuery Cheat Sheet
http://www.cheat-sheets.org/saved-copy/Jquery-Cheat-Sheet-1.2.pdf</description>
		<content:encoded><![CDATA[<p>jQuery Cheat Sheet<br />
<a href="http://www.cheat-sheets.org/saved-copy/Jquery-Cheat-Sheet-1.2.pdf" rel="nofollow">http://www.cheat-sheets.org/saved-copy/Jquery-Cheat-Sheet-1.2.pdf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: abhishekhurana</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-94</link>
		<dc:creator>abhishekhurana</dc:creator>
		<pubDate>Mon, 07 Jul 2008 16:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-94</guid>
		<description>you are right...plz see George comments for a better impl. I was not aware of jquery accepting css selector arguments.</description>
		<content:encoded><![CDATA[<p>you are right&#8230;plz see George comments for a better impl. I was not aware of jquery accepting css selector arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kentaromiura</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-93</link>
		<dc:creator>kentaromiura</dc:creator>
		<pubDate>Mon, 07 Jul 2008 15:54:49 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-93</guid>
		<description>If you look at my implementation i check if the browser support evaluate, otherwise it will fallback to the standard way of doing this using a standard way of iterating throught the dom,
i think jquery will use a simil approach under the hood, what it make a doubt in your method is that you&#039;re chaining togever quite lot of methods.

I see lots of map and filter, and everyone of this method iterate a collection.</description>
		<content:encoded><![CDATA[<p>If you look at my implementation i check if the browser support evaluate, otherwise it will fallback to the standard way of doing this using a standard way of iterating throught the dom,<br />
i think jquery will use a simil approach under the hood, what it make a doubt in your method is that you&#8217;re chaining togever quite lot of methods.</p>
<p>I see lots of map and filter, and everyone of this method iterate a collection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: abhishekhurana</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-92</link>
		<dc:creator>abhishekhurana</dc:creator>
		<pubDate>Mon, 07 Jul 2008 15:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-92</guid>
		<description>@Chris
I didn&#039;t mentioned it uprightly, though I did took the worst case scenario and built my write up over it to talk abt doing it using css selectors (given by jquery). I should elaborate more on how jquery is doing it by as well  falling back on xpath (to use document.evaluate) or regex match.
Your approach of css selectors looks a better one, only if it works for me. Nevertheless it comes with its own tradeoff. What if I need to arrive to a class name only thru some conditional checks. Then I may again end up adding class to elements (by iterating)

The reason for providing the implementation suggests that this is not a native method but one can add to the DOM.
Prototype does that as well, but thats been deprecated.
Safari 3.1 has a native support for this method, suit follwed by FF3 n Opera 9.5, but can&#039;t say how quickly we move our apps to these new versions? IE is still far from it.

@George
The optimization looks good. It works.

@kentaromiura
As for document.evaluate, does IE support it? FF2, FF3 &amp; Opera 9.27 does, not sure of other versions.</description>
		<content:encoded><![CDATA[<p>@Chris<br />
I didn&#8217;t mentioned it uprightly, though I did took the worst case scenario and built my write up over it to talk abt doing it using css selectors (given by jquery). I should elaborate more on how jquery is doing it by as well  falling back on xpath (to use document.evaluate) or regex match.<br />
Your approach of css selectors looks a better one, only if it works for me. Nevertheless it comes with its own tradeoff. What if I need to arrive to a class name only thru some conditional checks. Then I may again end up adding class to elements (by iterating)</p>
<p>The reason for providing the implementation suggests that this is not a native method but one can add to the DOM.<br />
Prototype does that as well, but thats been deprecated.<br />
Safari 3.1 has a native support for this method, suit follwed by FF3 n Opera 9.5, but can&#8217;t say how quickly we move our apps to these new versions? IE is still far from it.</p>
<p>@George<br />
The optimization looks good. It works.</p>
<p>@kentaromiura<br />
As for document.evaluate, does IE support it? FF2, FF3 &amp; Opera 9.27 does, not sure of other versions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kentaromiura</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-91</link>
		<dc:creator>kentaromiura</dc:creator>
		<pubDate>Mon, 07 Jul 2008 14:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-91</guid>
		<description>document.evaluate is way faster..

see 

http://mykenta.blogspot.com/2007/10/getelementbyclass-revisited.html

or 

http://www.devpro.it/code/133.html

for a crosslibrary function.</description>
		<content:encoded><![CDATA[<p>document.evaluate is way faster..</p>
<p>see </p>
<p><a href="http://mykenta.blogspot.com/2007/10/getelementbyclass-revisited.html" rel="nofollow">http://mykenta.blogspot.com/2007/10/getelementbyclass-revisited.html</a></p>
<p>or </p>
<p><a href="http://www.devpro.it/code/133.html" rel="nofollow">http://www.devpro.it/code/133.html</a></p>
<p>for a crosslibrary function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heilmann</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-90</link>
		<dc:creator>Chris Heilmann</dc:creator>
		<pubDate>Mon, 07 Jul 2008 13:45:54 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-90</guid>
		<description>George, under the hood this is still a loop (or on Firefox one native call and then a loop). :)</description>
		<content:encoded><![CDATA[<p>George, under the hood this is still a loop (or on Firefox one native call and then a loop). <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-89</link>
		<dc:creator>George</dc:creator>
		<pubDate>Mon, 07 Jul 2008 13:15:14 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-89</guid>
		<description>How about:

&lt;code&gt;$(&quot;#mainDiv div.xyzClass&quot;).hide();&lt;/code&gt;

jQuery accepts any css selector as it&#039;s argument. No need to filter. And it has a built in method for hiding elements.</description>
		<content:encoded><![CDATA[<p>How about:</p>
<p><code>$("#mainDiv div.xyzClass").hide();</code></p>
<p>jQuery accepts any css selector as it&#8217;s argument. No need to filter. And it has a built in method for hiding elements.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heilmann</title>
		<link>http://pitfalls.wordpress.com/2008/07/07/querying-it-jquery-way-getelementsbyclass/#comment-88</link>
		<dc:creator>Chris Heilmann</dc:creator>
		<pubDate>Mon, 07 Jul 2008 12:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://pitfalls.wordpress.com/?p=27#comment-88</guid>
		<description>Hmm why not....

&lt;code&gt;
window.onload  = function(){
  document.body.className = &#039;jsenabled&#039;;
}
&lt;/code&gt;

and in your CSS: 

body.jsenabled .triggerClass {
position:absolute;
left:-4000px;
/* or any other - screenreader friendly hiding method */
}

You will never be as fast as the CSS parser. 

Furthermore, if you write a getElementsByClassName these days, check that it doesn&#039;t exist natively, as a lot of browsers support this now.</description>
		<content:encoded><![CDATA[<p>Hmm why not&#8230;.</p>
<p><code><br />
window.onload  = function(){<br />
  document.body.className = 'jsenabled';<br />
}<br />
</code></p>
<p>and in your CSS: </p>
<p>body.jsenabled .triggerClass {<br />
position:absolute;<br />
left:-4000px;<br />
/* or any other &#8211; screenreader friendly hiding method */<br />
}</p>
<p>You will never be as fast as the CSS parser. </p>
<p>Furthermore, if you write a getElementsByClassName these days, check that it doesn&#8217;t exist natively, as a lot of browsers support this now.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
