Erro de acesso variável de formulário função
-
22-12-2019 - |
Pergunta
No chrome função, mas no IE10 erro de retorno para o nome da variável na função, como eu posso ter acesso a essa variável da função?
$('.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);
});
});
Solução
Tente:
$('.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
});
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow