How to dynamically change a web page’s title?

I have a webpage that implements a set of tabs each showing different content. The tab clicks do not refresh the page but hide/unhide contents at the client side.

Now there is a requirement to change the page title according to the tab selected on the page ( for SEO reasons ). Is this possible? Can someone suggest a solution to dynamically alter the page title via javascript without reloading the page?


Update: as per the comments and reference on SearchEngineLand
most web crawlers will index the updated title. Below answer is obsolete, but the code is still applicable.

You can just do something like, document.title = "This is the new
page title.";
, but that would totally defeat the purpose of SEO. Most
crawlers aren’t going to support javascript in the first place, so
they will take whatever is in the element as the page title.

If you want this to be compatible with most of the important crawlers,
you’re going to need to actually change the title tag itself, which
would involve reloading the page (PHP, or the like). You’re not going
to be able to get around that, if you want to change the page title in
a way that a crawler can see.