[jQuery] custom selectors :even/:odd ind find() ? [u]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=531103122-18052006>I've simple question
about using the special selectors from inside the find()
function:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=531103122-18052006><FONT face=Arial size=2>the following
function can be used to decorate the table with the given tabId with stripes and
a row highlighning effect on rows mousover. </FONT></SPAN></DIV>
<DIV><SPAN class=531103122-18052006><FONT face=Arial size=2>It works great, but
i think the implementation is a little bit inperformant because of the multiple
$() querys.</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2><FONT face="Courier New"></FONT></FONT> </DIV>
<DIV><FONT face=Arial size=2><FONT face="Courier New">function decorate(tabId)
{<BR> var tabsel =
"#"+tabId+">tbody>tr";<BR> $(tabsel+":even").addClass("even");<BR> $(tabsel+":odd").addClass("odd");<BR> $(tabsel).hover(<BR> function(){$(this).addClass("h");},<BR>
function(){$(this).removeClass("h");});<BR>}</FONT><BR></DIV></FONT>
<DIV><FONT><SPAN class=531103122-18052006><FONT face=Arial size=2>so I tryed the
following, but the even/odd class decoration is not working (ie 6, moz 1.7,
firefox 1.5). find() returns more elements than the original
query!?</FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>function fast<SPAN
class=531103122-18052006>er</SPAN>Decorate(tabId) {<BR> var tabsel =
"#"+tabId+">tbody>tr";<SPAN class=531103122-18052006>
//#myTab>tbody>tr</SPAN><BR> $(tabsel)<SPAN
class=531103122-18052006>
//.size()==6</SPAN><BR> .find(":even")<SPAN
class=531103122-18052006>
//.size()==19???</SPAN><BR><SPAN
class=531103122-18052006> </SPAN> .addClass("even")<BR> <SPAN
class=531103122-18052006> </SPAN> .end()<BR>
.find(":odd")<BR> <SPAN class=531103122-18052006> </SPAN>
.addClass("odd")<BR> <SPAN
class=531103122-18052006>
</SPAN>.end()<BR> .hover(<BR> <SPAN
class=531103122-18052006>
</SPAN>function(){$(this).addClass("h");},<BR> <SPAN
class=531103122-18052006>
</SPAN>function(){$(this).removeClass("h");});<BR></FONT><FONT><FONT
face="Courier New" size=2>}</FONT></FONT></DIV><FONT face=Arial>
<P align=left><FONT size=2><SPAN class=531103122-18052006>any ideas? What is the
advanced way to jquery the problem?</SPAN></FONT></P>
<P align=left><FONT size=2><SPAN class=531103122-18052006>regards, stefan
flick</SPAN></FONT></P>
<P align=left><FONT face="Courier New" color=#000080
size=2>********************************************<BR>*** Stefan Flick<BR>***
2333 Leopoldsdorf b. Wien<SPAN class=531103122-18052006>, </SPAN>Austria<BR>***
email: <SPAN class=531103122-18052006><A
href="mailto:devsteff@gmx.de">dev</SPAN>steff@gmx.de</A><BR></FONT><FONT
size=2><FONT face="Courier New"
color=#000080>********************************************<BR></FONT>
</FONT></P></FONT>
<DIV> </DIV></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/