Stay on a current tab after after submitting a form using jQuery

后端 未结 8 599
一生所求
一生所求 2021-01-18 08:14

I\'m trying to stay on a specif tab ( in this case tab2 ) but after clicking the submit button the tab reverts to tab 1 which has the default class of active. I have hit a b

相关标签:
8条回答
  • 2021-01-18 08:55

    It's so easy. after submit your form you have to click on tab you want automatically. first put Id in your tabs like this <a href='#tab1' id=idtab1 > <a href='#tab2' id=idtab2 > and after that just use the Javascript before body close

    <script> document.getElementById('idtab2').click(); </script>

    0 讨论(0)
  • 2021-01-18 08:57

    You can specify tab in URL. A tab is an anchor in a URL like: yourURL/#tab

    <form id="form2" action="#tab2" method="post">            
    
    </form>
    
    0 讨论(0)
提交回复
热议问题