저는 이걸 가지고 머리를 쓰려고했는데, 보통 jQuery 갈라진 틈이 있습니다. 그러나이 문제를 해결하기 위해 Magento 확장을 가지고 프로토 타입을 사용하고 있습니다. 오류 :잡히지 않은 TypeError : 정의되지 않은 'innerHTML'속성을 읽을 수 없습니다.
오류가 발생합니다 : Uncaught TypeError: Cannot read property 'innerHTML' of undefined
해당 페이지에서 특정 HTML의 존재 여부를 확인해야하기 때문에 짐작할 수 있습니다 (javascript 파일은 모든 페이지에 나타나므로 관련 HTML이 없을 수도 있습니다).
원래 나는 spConfig undefined
을 나는 if ((typeof spConfig == 'undefined') || !spConfig) {
라인에 넣어 이유입니다 얻고 있었다
원래의 코드는 다음과 같습니다
document.observe("dom:loaded", function() {
if(spConfig.config.dynamics == 1 && spConfig.config.showbottom == 1){
$$('.product-options-bottom')[0].insert({top: new Element('p', {id:'bottom-avail', class:'availability'}).update($$('p.availability')[0].innerHTML)});
if(spConfig.config.showship == 1){
$('bottom-avail').insert({after: new Element('p', {id:'bottom-shipsin', class:'shipsin'}).update($$('p.shipsin')[0].innerHTML)}); }
}
});
내가 변화 시도
document.observe("dom:loaded", function() {
if ((typeof spConfig == 'undefined') || !spConfig) {
} else {
if(spConfig.config.dynamics == 1 && spConfig.config.showbottom == 1){
if($$('p.availability') != 'undefined'){
$$('.product-options-bottom')[0].insert({top: new Element('p', {id:'bottom-avail', class:'availability'}).update($$('p.availability')[0].innerHTML)});
}
if(spConfig.config.showship == 1){
if($$('p.shipsin') != 'undefined'){
$('bottom-avail').insert({after: new Element('p', {id:'bottom-shipsin', class:'shipsin'}).update($$('p.shipsin')[0].innerHTML)});
}
}
}
}
});
에 그러나 나는 여전히
$$()
방법은 목록을 반환
$$('.product-options-bottom')[0].insert({top: new Element('p', {id:'bottom-avail', class:'availability'}).update($$('p.availability')[0].innerHTML)});
클래스 힌트를 주셔서 감사합니다. 다음 번 오류를 해결했습니다. 길이 확인을 한 번 해봅시다. –