replace, jQuery

Replace URL location index.html to index_th.html


$(document).ready( function() {
  $(".btnThailand").click(function(){
    var translate=window.location.href;
    translate=translate.replace("index.html","index_th.html");
    window.location = translate;
  });
});

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FString%2Freplace

http://stackoverflow.com/questions/2145988/string-replace-in-jquery

Advertisements