skip to Main Content

Jquery – How to change language part of URL by using regex in this example?

Situation: When an id element selected, get the current URl and change the /en/ part to other language current URL http://127.0.0.1:5500/2023/en/activities_summary.html I want to change it to http://127.0.0.1:5500/2023/tc/activities_summary.html code: $('#tc').on('click',function(){ if(location.href.match(//(?:en|sc)//)){ location.replace(/^.+?/(?:en|sc)//,'tc') } })

VIEW QUESTION
Back To Top
Search