我有一系列頁面,我需要獲取按鈕的特定代碼。 我想將URL中的代碼放入jQuery的變量中。jQuery獲取URL的最後部分
一個例子網址是www.example.com/folder/code/12345/
我想在一個叫(SITECODE)
預先感謝任何答案變量的數字部分。
的jQuery /僞代碼:
var siteCode;
// start function
function imageCode(){
siteCode // equals number part of URL
$('.button').attr('src', 'http:www.example.com/images/'+siteCode+'.jpg');
}
http://stackoverflow.com/questions/4758103/last-segment-of-url可能的重複數據刪除文件夾層次增加 –