내 IDE, RubyMine은,이 "잠재적으로 잘못된"입니다 말합니다.왜이 자바 스크립트가 올바르지 않습니까?
내 IDE가var top_up_miles
라인, "
this
의 무효 가능성이 사용하는 자바 스크립트
this
위한이 검사에 말한다
function update_top_up_prices_via_localStorage(){
var index = localStorage.getItem("volxs");
$('.product-inner').each(function(){
var product = this.getAttribute('data-product-miles');
var cpm = ((localStorage.getItem("cpm_by_volxs_"+product)).split(","))[index];
$(this).find('table tbody tr td').each(function(){
var top_up_miles = Number(this.getAttribute('data-topup-miles'));
var price = Number(top_up_miles * cpm * 1.06);
price = price.toFixed(2);
$(this).text('\u00A3'+price);
})
});
}
이 같이 폐쇄에 동일로 외부 상황.
JS는?이 쓰기 수있는 더 나은 방법이 있나요?
. 그것은 IE8에서 작동하지 않습니다. 크롬과 IE9에서 잘 작동이 잘못인가
RubyMine에 대해 잘 모르지만 (사실 그게 뭔지는 모르겠지만) 코드는 다소 복잡해 보입니다. 순수한 JavaScript와 jQuery의 이상한 혼합. '$ (this) .attr ('data-topup-miles')'을 사용해보십시오. IE8에서 작동하지 않는다는 것은 무엇을 의미합니까? 오류가 있습니까? 잘못된 값 (IE8은 다른 브라우저에서'toFixed'를 다른 방식으로 처리하는 것 같습니다)? 또한 IE8에는 콘솔 ('F12')이 있습니다. 오류가 있는지 확인하십시오. 실제로 페이지를로드하기 전에 콘솔을 실행해야합니다. – freakish