Hi.. i am trying something very simple, but somehow...
var postContentClass = "postcontent"; // classname
$$(postContentClass).each(
Element.toggle();
);
Now in my HTML i have 10 time <div class="postcontent"> but $$
does not find
anything. why?
I already put an alert() into the each() but the alert only occurs 1 time.
:(
Any ideas?
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Reply to self:
Nevermind.. i use getElementsByClassName ..
somehow $$ does not accept variables.
For the record, here is how it works for me:
document.getElementsByClassName(postContentClass).each(
function(element) {
Element.toggle(element);
}
);
Thanks for reading anyways.
Best regards,
Kjell
On 7/15/06, Kjell Bublitz
<m3nt0r.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi.. i am trying something very simple, but somehow...
>
> var postContentClass = "postcontent"; // classname
>
> $$(postContentClass).each(
> Element.toggle();
> );
>
> Now in my HTML i have 10 time <div class="postcontent"> but
$$ does not
> find anything. why?
> I already put an alert() into the each() but the alert only occurs 1 time.
> :(
>
> Any ideas?
>
>
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 7/15/06, Kjell Bublitz <m3nt0r.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi.. i am trying something very simple, but somehow... > > var postContentClass = "postcontent"; // classname > > $$(postContentClass).each( > Element.toggle(); > ); > > Now in my HTML i have 10 time <div class="postcontent"> but $$ does not find > anything. why? > I already put an alert() into the each() but the alert only occurs 1 time. > :( > > Any ideas?maybe you should use ".postcontent" instead of "postcontent". $$ takes a css selector as argument. regards, hans
Doh! You are of course right.. I thought $$ would not need that "dot".. Thank you. On 7/15/06, Hans Gremmen <rails-spinoffs-mvqB/VeXuE7k1uMJSBkQmQ@public.gmane.org> wrote:> > On 7/15/06, Kjell Bublitz <m3nt0r.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi.. i am trying something very simple, but somehow... > > > > var postContentClass = "postcontent"; // classname > > > > $$(postContentClass).each( > > Element.toggle(); > > ); > > > > Now in my HTML i have 10 time <div class="postcontent"> but $$ does not > find > > anything. why? > > I already put an alert() into the each() but the alert only occurs 1 > time. > > :( > > > > Any ideas? > > maybe you should use ".postcontent" instead of "postcontent". $$ takes > a css selector as argument. > > regards, > hans > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
You''ll need to send a function as argument to each and (like others
said) use a dot
$$(".postContentClass").each(function(element) {
Element.toggle(element);
});
or call it without paranthes so it''s passed as a reference and
executed in the each loop and not executed directly.
$$(".postContentClass").each(Element.toggle);
Martin
On 7/15/06, Kjell Bublitz
<m3nt0r.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi.. i am trying something very simple, but somehow...
>
> var postContentClass = "postcontent"; // classname
>
> $$(postContentClass).each(
> Element.toggle();
> );
>
> Now in my HTML i have 10 time <div class="postcontent"> but
$$ does not find
> anything. why?
> I already put an alert() into the each() but the alert only occurs 1 time.
> :(
>
> Any ideas?
>
>
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
>