==================
HTML:
<form action="/EditWebSiteLinksPOrderAjax" id="postForm"> | |
<ul id="sortableUL"> | |
<li id="sort_0" class="ui-state-default"> | |
<input id="order0" name="POrder" type="hidden" value="0" /> | |
<input id="WebSiteLinksId" name="WebSiteLinksId" type="hidden" value="2" /> | |
</li> | |
<li id="sort_1" class="ui-state-default"> | |
<input id="order1" name="POrder" type="hidden" value="1" /> | |
<input id="WebSiteLinksId" name="WebSiteLinksId" type="hidden" value="3" /> | |
</li> | |
<li id="sort_2" class="ui-state-default"> | |
<input id="order2" name="POrder" type="hidden" value="2" /> | |
<input id="WebSiteLinksId" name="WebSiteLinksId" type="hidden" value="5" /> | |
</li> | |
<li id="sort_3" class="ui-state-default"> | |
<input id="order3" name="POrder" type="hidden" value="3" /> | |
<input id="WebSiteLinksId" name="WebSiteLinksId" type="hidden" value="6" /> | |
</li> | |
</ul> | |
<p> | |
<input type="submit" value="確定" /> | |
</p> | |
</form> |
【JQuery】:
var $form = $("#postForm");
(1) $form.find('input[name="POrder"]').map(function () { return $(this).attr("value") })
= ["0", "1", "2", "3"]
(2) $form.find('input[name="POrder"]').serializeArray()
=[Object { name="POrder", value="0"}, Object { name="POrder", value="1"}, Object { name="POrder", value="2"}, Object { name="POrder", value="3"}]