Question

In chrome function but in IE10 return error for the variable name in the function, how I can have access to this variable from the function?

  $('.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);
        });
  });
Was it helpful?

Solution

Try:

 $('.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
        });
  });

See Setting href attribute at runtime

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top