Hi,

The first version is correct. It inserts a paragraph at the top of any
element (not just divs) that has the class "main". I was able to drop
it into a test page and run it without trouble, except that I
literally copied it from the GGroups display of your message and it
had invisible characters in it (character code A0). Once I got rid of
those, it worked fine. No idea if that was a GGroups thing (normally
copying code from GGroups is fine) or if you pasted the code at your
end and it really has these weird characters in it. (If so, try
getting rid of them and it may solve the problem.)

You can also do it like this:

function adCorner() {
    $$(".main").invoke('insert', {top: '<p>My Element</p>'});
}

...but there was nothing wrong with your first version, especially if
you have more logic than just calling 'insert' (which seems likely).

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Mar 26, 5:05 pm, "[email protected]"
<[email protected]> wrote:
> Hello,
>
> im going crazy by simply selecting a DIV Element with class.
>
> I want to add to each <div class=main"></div> a aditional Element.
> I tried two versions:
>
> <script type="text/javascript">
>     function adCorner() {
>       $$(".main").each(function(item) {
>                         item.insert({top: '<p>My Element</p>'})
>       });
>     }
> </script>
>
> and this
>
> <script type="text/javascript">
>       $$(".main").each().insert({top: '<p>My Element</p>'});
> </script>
>
> But nothing happend.
>
> Its so easy with ID's but its not working with classes.
>
> Thanks for help.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to