动态输出html代码,调用前台js函数,如何将“自身”当做参数传递给前台函数??
function GetAllStoreByCityName(cityName) {
$.ajax({
type: "get",
async: false,
url: "AjaxValidate/GetAllStoreByCityName.aspx?cityName=" + encodeURIComponent(cityName),
success: function(data, textStatus) {
document.getElementById("store").innerHTML = data;
setTimeout('$("#store ul:first").find("li a:first").click();', 1000);
$("#store ul:first").find("li a:first").addClass("red");
},
error: function() {
alert("error !");
}
});
}
上面是前台定义好的js函数,后台我动态输出a标签我想每次点击a标签是调用该函数,并且改变a标签的背景色,该怎么做????谢谢!
function GetAllStoreByCityName(cityName) {
$.ajax({
type: "get",
async: false,
url: "AjaxValidate/GetAllStoreByCityName.aspx?cityName=" + encodeURIComponent(cityName),
success: function(data, textStatus) {
document.getElementById("store").innerHTML = data;
setTimeout('$("#store ul:first").find("li a:first").click();', 1000);
$("#store ul:first").find("li a:first").addClass("red");
},
error: function() {
alert("error !");
}
});
}
上面是前台定义好的js函数,后台我动态输出a标签我想每次点击a标签是调用该函数,并且改变a标签的背景色,该怎么做????谢谢!
调这个函数?
GetAllStoreByCityName那就$('a').click(GetAllStoreByCityName)