任何人都可以看到我在这里出错的地方,我试图获得链接后的最后一个字符,并放入一个变量中,但是我使用的代码返回/。在链接中提取?=后的字符
我的代码是:
$("#dvPartial").on('click', '.dvPagerCities a', function (event) {
alert('click detected');
var city = ($('input#hdnCountry').val());
alert(city);
var link = $('a').attr('href');
//var getEqualPosition = link.indexOf('?p='); //Get the position of '='
var getEqualPosition = link.indexOf('='); //Get the position of '='
var number = link.substring(getEqualPosition + 1); //Split the string and get the number.
我的链接是
<a href="/Weather/Index/Australia?p=2">»</a>
我认为正在发生的事情是它拿起1 =。
我的理论是这样的。
1)检测单击事件
2)获取引发事件
3)提取p的值的链接,
p可为1个diget,2个digets或3个digets 。
任何帮助将不胜感激,因为它似乎不久我解决1问题,然后出现另一个问题。
感谢
乔治
可能重复http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values) –
它适用于我。看到这个例子http:// jsfiddle。净/ Dineshkani/7QHr4/ – Dineshkani
嗨Dineshkani其工作在jsfiddle,或部分更新之外的静态链接,但不是在我的网页上创建链接时, – CareerChange