提交我的的jQuery產生的輸入列表重命名的屬性名稱如果一個之前被刪除的jQuery
<input type='text' name='field[0]' />
<input type='file' name='field[1]' />
<textarea name='field[2]' value='' />
<textarea name='field[3]' value=''/>
現在,用戶必須刪除字段與按鈕的可能性,例如:如果我刪除字段[2]它導致這樣的:
<input type='text' name='field[0]' />
<input type='file' name='field[1]' />
<textarea name='field[3]' value=''/>
問題是增加後的字段不再適合以後,因爲不是像0,1,2,3 ...這樣的列表我有0,1,3 ...
我只是想更改另一件事:用戶可以通過拖拽字段來改變順序。字段的數字屬性已被刪除以適應其他字段的遞增字段。
另一件事:用戶可以通過拖放字段來更改順序。所以如果1場被刪除後場右側一定要以數位等
的代碼刪除字段:
$("#deletebtn").live("click", function(){
$(this).parent("li").remove();
});
任何幫助將是非常讚賞。
感謝您的回答!我試過,如果我刪除一個字段的索引不會改變,例如:我點擊刪除字段[2],其他人不改變他們的索引。任何想法? – user990463
不知道,除非你鏈接到它使用的頁面:) – Esailija
對不起,它是本地的:/也許這是因爲輸入是由jQuery生成 – user990463