Remember which tab was active after refresh

前端 未结 17 2165
眼角桃花
眼角桃花 2020-11-27 04:43

I\'m using jquery tabs on a web page and when the page is refreshed it loses what ever tab I had been on and goes back to the first tab.

Has anyone come across this

17条回答
  •  [愿得一人]
    2020-11-27 05:12

    I assume that you are using jQuery UI tabs ,

    here is an example of using tabs + cookies to save the last clicked tab

    http://jqueryui.com/demos/tabs/#cookie

    demo : open this link http://jqueryui.com/demos/tabs/cookie.html

    the close it and re open it and you will see the same clicked tab

    update: after 3 years of this answer jquery ui has deprecated the cookie option : http://jqueryui.com/upgrade-guide/1.9/#deprecated-cookie-option.

    but you can still append take a look here if this fits your needs or not https://stackoverflow.com/a/14313315/109217

提交回复
热议问题