This is what you would want to do:
$("#gallery li:first").before("<li>testing</
li>").hide().slideDown("slow")

On Jul 3, 11:51 am, pek <[EMAIL PROTECTED]> wrote:
> I have a small problem when dealing with effects. Warning: Noob
> question ahead.
>
> Currently I have a list of items
> <ul id="gallery">
>   <li>test</li>
>   <li>test2</li>
> </ul>
>
> alert($("#gallery li:first").html()) will correctly echo "test".
> If I want to add a new element before that with a slideDown effect, I
> use this line:
> $("#gallery li:first").before().html("<li>testing</
> li>").hide().slideDown("slow")
>
> Although this correctly adds the line and smoothly slides it down, now
> the list is like this:
> <ul id="gallery">
>   <li style="display: block;">
>     <li>testing</li>
>   </li>
>   <li>test</li>
>   <li>test2</li>
> </ul>
>
> The extra li with the style is added by jQuery for the effect. This
> isn't a problem until you want again to add something before the first
> element.
> Now alert($("#gallery li:first").html()) incorrectly (well, correctly,
> but not what I want anyway) returns "<li>testing</li>" instead of
> "testing" which means that if I try to do the same effect with the
> same code it will not add before, rather, it will replace it and do
> the effect again.
>
> Any help?
>
> Thank you in advance.
> Panagiotis

Reply via email to