开发者

how to get a variable from a link using jquery and php?

开发者 https://www.devze.com 2023-04-02 05:35 出处:网络
i have this script on jsfiddle basically this links: <a id=\"mine_click\" href=\"#?test=123\">test</a> |

i have this script on jsfiddle

basically this links:

 | <a id="mine_click" href="#?test=123">test</a> | 
 | <a id="mine_click" href="#?test=123">test1</a开发者_如何学编程> | 
 | <a id="mine_click" href="#?test=123">test2</a> | 
 | <a id="mine_click" href="#?test=123">test3</a> | 

when i click on one of them i manage to change tabs but i want that test var to fallow and be displayed in the respective tab

any ideas?


You could use this function

function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

to get the variable and then print it.

fiddle here: http://jsfiddle.net/HysJ6/10/

0

精彩评论

暂无评论...
验证码 换一张
取 消