1 回答

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊
如果在提交表格之前要檢查確認(rèn),則必須使用表格中的<input/>is of 。在這種情況下,您可以在偵聽器中將 as 參數(shù)作為實(shí)現(xiàn)參數(shù)傳遞(由于單擊事件)。type="submit"preventDefault()eEventMouseEvent
例如 :
$(':input[name=updatePassword]').click(function(e) { // <-- e implements Event
? ? e.preventDefault(); // <-- prevent the submit of the form
? ? var answerProceed = confirm("Do you wish to proceed with the changes?");
? ? if (answerProceed) {
? ? ? ? var form = $("form[name=form1]");
? ? ? ? // var form = e.currentTarget.form; you can do this
? ? ? ? // var form = this.form; or you can do this, "this" is implicit clicked element
? ? ? ? form.attr("action", '<s:url beanclass="c.c.i.c.app.profile.ui.ChangePasswordAction" event="update"/>');
? ? ? ? form.submit();
? ? }
? ? else {
? ? ? ? return false;
? ? }
});
.form
您可以通過對(duì)元素執(zhí)行操作來訪問元素的形式
添加回答
舉報(bào)