在chrome函数中,但在IE10中函数中变量名的返回错误,我怎么能从函数中访问这个变量?
$('.kpit').on('click', function() {
var url = $(this).attr('id');
var name = $(this).attr('href');
$('.kpi').html('');
$.post(url, {idKpi: id}, function(result) {
$(name).html(result);
});
});
答案 0 :(得分:1)
尝试:
$('.kpit').on('click', function() {
var name = $(this).attr('id');
var element = $(this); //Removed the .attr('href'), as that would store the URL, not the element.
$('.kpi').html('');
$.post(name, {idKpi: id}, function(result) {
$(element).attr('href',result); //Set the HREF by using .attr, not .html
});
});