Hi all Icome from China, I love Prototype very much, and like to use $$ selector very much, but I have seen a feature of jQuery like this: look at the code <head><script language="JavaScript" type="text/javascript" src=" jquery-latest.js"></script> <style> .ttt { background-color:#00FF00} </style> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <script> $(document).ready(function(){ $('tr:odd').addClass('ttt'); }) </script> <body> <table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <td>d</td> <td>a</td> </tr> <tr> <td>d</td> <td>s</td> </tr> <tr> <td>s</td> <td>d</td> </tr> <tr> <td>a</td> <td>s</td> </tr> <tr> <td>s</td> <td>s</td> </tr> </table> I love this selector because it supports "tr:odd", I find that thing amazing, can I achieve same effect using Prototype's $$ function? Thanks for any responses. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
a.rebholz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-08 09:32 UTC
Re: A $$ selector question
Hello, I am by far no prototype pro but this should do the job: var oddtrs = $$('table > tr:nth-child(odd)'); oddtrs.invoke('addClassName','ttt'); requires Prototype 1.5.1 See: http://www.prototypejs.org/api/utility/dollar-dollar regards, Alex 2007/5/8, su weisi <afcn007@gmail.com>:> > Hi all > Icome from China, I love Prototype very much, and like to use $$ selector > very much, but I have seen a feature of jQuery like this: look at the code > > > <head><script language="JavaScript" type="text/javascript" src=" > jquery-latest.js"></script> > <style> > .ttt { background-color:#00FF00} > > </style> > <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> > <title>无标题文档</title> > </head> > <script> > $(document).ready(function(){ > $('tr:odd').addClass('ttt'); }) > </script> > <body> > <table width="400" border="0" cellspacing="0" cellpadding="0"> > <tr> > <td>d</td> > <td>a</td> > </tr> > <tr> > <td>d</td> > <td>s</td> > </tr> > <tr> > <td>s</td> > <td>d</td> > </tr> > <tr> > <td>a</td> > <td>s</td> > </tr> > <tr> > <td>s</td> > <td>s</td> > </tr> > </table> > > I love this selector because it supports "tr:odd", I find that thing > amazing, can I achieve same effect using Prototype's $$ function? Thanks for > any responses. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
afcn007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-08 09:59 UTC
Re: A $$ selector question
Tks, your method do it. But it seems I should use $$("table tr:nth-child(odd)") instead of using $$("table > tr:nth-child(odd)") I do not know what does ">" stands for, it seems to me none sense. but thank you all the same, however the jQuery is something shorter that $ $, jQuery usually is shorter than others, but I still love Prototype.... On May 8, 5:32 pm, a.rebh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Hello, > > I am by far no prototype pro but this should do the job: > > var oddtrs = $$(''table > tr:nth-child(odd)''); > oddtrs.invoke(''addClassName'',''ttt''); > > requires Prototype 1.5.1 > > See:http://www.prototypejs.org/api/utility/dollar-dollar > > regards, > Alex > > 2007/5/8, su weisi <afcn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > > > Hi all > > Icome from China, I love Prototype very much, and like to use $$ selector > > very much, but I have seen a feature of jQuery like this: look at the code > > > <head><script language="JavaScript" type="text/javascript" src=" > > jquery-latest.js"></script> > > <style> > > .ttt { background-color:#00FF00} > > > </style> > > <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> > > <title>无标题文档</title> > > </head> > > <script> > > $(document).ready(function(){ > > $(''tr:odd'').addClass(''ttt''); }) > > </script> > > <body> > > <table width="400" border="0" cellspacing="0" cellpadding="0"> > > <tr> > > <td>d</td> > > <td>a</td> > > </tr> > > <tr> > > <td>d</td> > > <td>s</td> > > </tr> > > <tr> > > <td>s</td> > > <td>d</td> > > </tr> > > <tr> > > <td>a</td> > > <td>s</td> > > </tr> > > <tr> > > <td>s</td> > > <td>s</td> > > </tr> > > </table> > > > I love this selector because it supports "tr:odd", I find that thing > > amazing, can I achieve same effect using Prototype''s $$ function? Thanks for > > any responses.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
afcn007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-08 10:00 UTC
Re: A $$ selector question
It seems invoke stands for each and call one function and with same para something like that, begin to know this method, TKS On May 8, 5:32 pm, a.rebh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Hello, > > I am by far no prototype pro but this should do the job: > > var oddtrs = $$(''table > tr:nth-child(odd)''); > oddtrs.invoke(''addClassName'',''ttt''); > > requires Prototype 1.5.1 > > See:http://www.prototypejs.org/api/utility/dollar-dollar > > regards, > Alex > > 2007/5/8, su weisi <afcn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > > > Hi all > > Icome from China, I love Prototype very much, and like to use $$ selector > > very much, but I have seen a feature of jQuery like this: look at the code > > > <head><script language="JavaScript" type="text/javascript" src=" > > jquery-latest.js"></script> > > <style> > > .ttt { background-color:#00FF00} > > > </style> > > <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> > > <title>无标题文档</title> > > </head> > > <script> > > $(document).ready(function(){ > > $(''tr:odd'').addClass(''ttt''); }) > > </script> > > <body> > > <table width="400" border="0" cellspacing="0" cellpadding="0"> > > <tr> > > <td>d</td> > > <td>a</td> > > </tr> > > <tr> > > <td>d</td> > > <td>s</td> > > </tr> > > <tr> > > <td>s</td> > > <td>d</td> > > </tr> > > <tr> > > <td>a</td> > > <td>s</td> > > </tr> > > <tr> > > <td>s</td> > > <td>s</td> > > </tr> > > </table> > > > I love this selector because it supports "tr:odd", I find that thing > > amazing, can I achieve same effect using Prototype''s $$ function? Thanks for > > any responses.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
su weisi a écrit :> $(document).ready(function(){ > $(''tr:odd'').addClass(''ttt''); })From 1.5.1: - Use $$(''tr:nth-child(odd)'').invoke(''addClassName'', ''ttt'') From 1.6.0 (quite some time ahead): - We''ll have cross-browser support for the DOMContentLoaded event that is equivalent to the ready method... Until then, you''d have to make do with the ''load'' event, which happens later, or use LoPro as an add-on to Prototype, which does feature this ''ready'' mechanism. ''HTH -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---