我是Jquery的新手,我想讓Jquery代碼獲取當前頁面的url,如果url包含某些字符串,然後加載遠程元素。Jquery根據當前頁面中的字符串加載遠程頁面元素
例如:
我有網頁網址是這樣的:
"http://......./Country/AU/result-search-to-buy"
"http://......./Country/CA/result-search-to-buy"
"http://......./Country/UK/result-search-to-buy"
部分「/國家/ AU」是什麼,我需要確定我要加載的頁面元素,那麼如果「 AU「如果從」/state-loader.html .state-CA「加載」/state-loader.html .state-AU「我加載我有一個內置模塊」{module_pageaddress }「來獲取當前頁面url的值,我只是不知道jquery logi c讓它工作。
我希望這樣的事情:
if {module_pageaddress} contains "/Country/AU/"
$('#MyDiv').load('state-loader.html .state-AU');
if {module_pageaddress} contains "/Country/CA/"
$('#MyDiv').load('state-loader.html .state-CA');
請幫助許多感謝。