在創建幾個portlet之後,添加帶有類addspace的最後一個div。
然後用.replaceWith和.addClass創建一個函數。返回的HTML的
$('.addspace').replaceWith(html);
例子:
<div class="portlet" id="portletname"> <!-- make sure portletname is unique -->
<div class="portlet-header">test</div>
<div class="portlet-content">test</div>
</div>
<!-- New addspace (replaceWith replaces the old one) -->
<div class="addspace" >
</div
添加portlet類按ID的div:
$('#portletname')
.addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
.find(".portlet-header")
.addClass("ui-widget-header ui-corner-all")
.prepend('<span class="ui-icon ui-icon-minusthick"></span>')
.end()
.find(".portlet-content");
時發生了什麼你'.addClass'?你能否取消在你的網頁上的評論,以便我們可以目睹錯誤? (當我在添加新div後執行代碼時,其他portlet不受影響。)順便說一下,很棒的評論,只有第一個有點苛刻。 – MvanGeest 2010-08-02 20:38:18
嗨。所有其他Portlet都會得到一個減號( - )以便最小化。 – Soliman 2010-08-02 20:42:18
感謝您的補充,忘記了第一個:)。刪除了評論星。 – Soliman 2010-08-02 20:43:25