views:

63

answers:

1

I know my jQuery, but sadly don't know much about Prototype.

$(function() {
     $('#home-gallery-container').append('<a href="/images/cobra_sale.jpg" alt="" rel="lightbox-home" id="special-home" ><img src="/images/tag.png" alt="Special" /></a>');
});

How would I do this in Prototype, or Magento's library if that adds anything extra.

Note in the sample above, I have taken into account jQuery.noConflict() etc

+2  A: 

This should work:

$('home-gallery-container').insert({
    bottom:'<a href="/images/cobra_sale.jpg" alt="" rel="lightbox-home" id="special-home" ><img src="/images/tag.png" alt="Special" /></a>'
});

See Element.Insert in Prototype's Docs.

Josh
FYI `insert()` defaults to `"bottom"` if just passed the html string directly.
Crescent Fresh
@Crescent: Thanks. I often forget what it default to and so I tend to explicitly state what I want where.
Josh