2010-02-19 19 views
1

我知道我的jQuery,但很遺憾對Prototype不太瞭解。我需要使用Prototype來做一些我可以很容易地在jQuery中做的事情

$(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>'); 
}); 

我該如何在Prototype或Magento的庫中做這件事,如果增加了額外的東西。在上面的示例中

注意,我考慮jQuery.noConflict()

+0

當你知道如何時,一切都很簡單:) – 2010-03-02 13:53:06

回答

3

這應該工作:

$('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>' 
}); 

Element.Insert in Prototype's Docs

+1

如果只是直接傳遞html字符串,FYI'insert()'默認爲'「bottom」'。 – 2010-02-19 02:30:35

+0

@新月:謝謝。我經常忘記它的默認設置,所以我傾向於明確說明我想要在哪裏。 – Josh 2010-02-19 03:17:21

相關問題