連載,我有以下的jsfiddle那裏我試圖序列化類:試圖在的jsfiddle
HTML:
<content>
<div class="portlet portlet_1 portlet_content_1 new">some content here</div>
<div class="portlet portlet_1 portlet_content_1 new">some content here</div>
<div class="portlet portlet_1 portlet_content_1 new">some content here</div>
<div class="portlet portlet_2 portlet_content_2 new">some content here</div>
<div class="portlet portlet_2 portlet_content_2 new">some content here</div>
<div class="portlet portlet_3 portlet_content_3 new">some content here</div>
</content>
<button>Serialize</button>
JS:
$("content").sortable();
$("button").on("click", function() {
var data = $("content").sortable("serialize", {
key: "item",
attribute: "class"
});
alert(data);
});
在警報,我應該得到:
項目= 1個&項目= 1個&項目= 1個&項目= 2 &項目= 2 &項目= 3
我不知道如何處理這一點,因爲每個div標籤都有多個類。
是否有人可以幫助我?
重複的走了。 – phenomnomnominal
今後,請在您的帖子中包含所有相關代碼,並且**不要**僅包含jsFiddle的鏈接。您的帖子應該獨立於任何其他資源;想想如果jsFiddle將來會發生什麼事情。 – Matt
您如何期望'sortable'從'class'屬性中提取您想要的數字? – lanzz