我想序列化我的表單中的數據,但它不工作。JQuery序列化不起作用
manage-user-form
是窗體的ID。
$('#manage-user-form').live('submit',function(e) {
e.preventDefault();
var firstname = $("#firstName").val();
var lastname = $("#lastName").val();
// this doesn't work
alert($(this).serialize())
// this doesn't work
var d = $('#manage-user-form').find('input,select,textarea').serialize();
alert(d);
// this does work
alert(firstname);
alert(lastname);
});
您應該使用.on而不是.live – CodingIntrigue
另一個「不能工作」的問題?來吧,你可以做得比這更好。查看本網站上的幫助,並瞭解如何提出問題。 「不工作」不是問題描述。我們應該猜測錯誤和預期/真實行爲嗎? – walther
我在1.3上沒有'on'功能。 – NaN