Asp.net 无法在Jquery的单击事件中设置href
您好,我正在尝试在RadioButtonList的click事件中使用Jquery设置href,但如果我将相同的代码用于document.ready事件,则该设置不起作用。它可以正常工作,但在click事件中不起作用。请给我一些建议Asp.net 无法在Jquery的单击事件中设置href,asp.net,javascript,jquery,Asp.net,Javascript,Jquery,您好,我正在尝试在RadioButtonList的click事件中使用Jquery设置href,但如果我将相同的代码用于document.ready事件,则该设置不起作用。它可以正常工作,但在click事件中不起作用。请给我一些建议 $(document).ready(function() { url = "Results.aspx?latitude=" +latitude + "&Longitude=" + longitude; $("a[href='http://w
$(document).ready(function() {
url = "Results.aspx?latitude=" +latitude + "&Longitude=" + longitude;
$("a[href='http://www.google.com/']").attr("href", url); // this works..
}
$('.rbl input').click(function() {
id = $(this).parent().children("input").val();
url = "Results.aspx?latitude=" + latitude + "&Longitude=" + longitude + "&ServiceCenterProductTypeId=" + id;
//alert(url);
$("a[href='http://www.google.com/']").attr("href", url); //this doesnt work....
});
});
在我看来,这一行后面有一个额外的右括号
}
:
$("a[href='http://www.google.com/']").attr("href", url); // this works..
您(可能)将AutoPostBack
属性设置为true,从而导致向服务器回发,从而重新加载整个页面
因此,Javascript中的更改将被回发覆盖。经度和纬度设置在哪里?