문제

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);
        });
  });
도움이 되었습니까?

해결책

노력하다:

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

보다 런타임 시 href 속성 설정

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top