반응형

document.getElementById('adminA').appendChild("<span class='sr-only'>(current)</span>");

위의 코드를 실행하면 

아래와 같은 에러가 발생합니다.

 

 

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.

대충 해석해보면 appendChild 는 Node 만 추가할 수 있다.

이런 얘기입니다.

따라서 위의 코드는 잘못된 코드이고

appendChild 를 사용하려면

 

var onSpan=document.createElement('span')

onSpan.innerHTML="(current)"

onSpan.classList.add('sr-only')

document.getElementById('adminA').appendChild(onSpan);

 

위와 같이 사용하시면 해결이 됩니다.

 

출처:

stackoverflow.com/questions/27079598/error-failed-to-execute-appendchild-on-node-parameter-1-is-not-of-type-no

 

Error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

I am trying to drag and drop an image on a div. The image does not get get dragged onto the div and gives the following error Uncaught TypeError: Failed to execute 'appendChild' on 'Node': paramet...

stackoverflow.com

반응형

+ Recent posts