例如,我有制表符(bootstrap、tabpanel),它可以更改 url,在单击它们时添加 #tab1、#tab2...。假设我从 #tab1 提交,并想跳转到 #tab2,该怎么做?我所拥有的是:
.
.
.
$(formObj).submit();
return false;
表单的操作为空( <form method="post">
)
最佳答案
您可以使用.tab("show")
函数,as specified in the Bootstrap documentation ,在表单提交后显示您想要的选项卡。
例如,如果您的表单位于 #tab1
中,并且您想在提交表单后移至 #tab2
中,则可以这样做(更改 #myTabs
为您正在使用的选项卡列表的 id
):
$(formObj).submit();
$('#myTabs a[href="#tab2"]').tab('show')
return false;
关于javascript - jQuery,有没有办法在表单提交后在 URL 中设置 anchor ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29651278/