2016-06-07 5 views
0

버튼을 클릭하자마자 "hello"에 경고하려고합니다. 위의 오류가 내 브라우저에서 발생하고 아래 HTML에서 볼 수 있듯이 오류의 원인을 알 수 없도록 버튼 링크 아래에 스크립트 링크를 추가합니다. 어떤 도움을 주셔서 감사합니다.TypeError : null의 속성 "removeAttribute"를 읽을 수 없습니다.

receiver.js

$(function(){ 
 
    $("#passform").click(function(){ 
 
\t \t alert("hello"); 
 
\t \t console.log("hello"); 
 
\t }); 
 
});

index.html을

<!DOCTYPE html> 
 
\t <html> 
 
\t <head> 
 
\t <link href="public/stylesheets/style.css" rel="stylesheets" /> 
 
\t </head> 
 

 
\t <body> 
 
\t \t <button type="submit" id="passform"></button> 
 

 
\t  <script type="scripi/javascript" src="C:/users/owner/desktop/steelVault/public/javascripts/receiver.js"></script> 
 
\t  <script type="scripi/javascript" src="C:/users/owner/desktop/steelVault/public/javascripts/jquery/jquery-2.2.4.min.js"></script> 
 
\t </body> 
 
\t </html>

+0

이것은 AdBlock 확장과 관련이있을 수 있습니다. http://stackoverflow.com/questions/38143879/cannot-read-property-removeattribute-of-null-cant-find-source-of-it –

답변

0

귀하의 receiver.js 파일이 명확하게 참조 jQuery를 사용하므로 이에 따라 달라집니다. 따라서, 당신은 이전에 의존하여 다른 파일 참조에 당신이 jQuery를 참조하는지 확인해야합니다 :이 외에도

<script type="script/javascript" src="C:/users/owner/desktop/steelVault/public/javascripts/jquery/jquery-2.2.4.min.js"></script> 
<script type="script/javascript" src="C:/users/owner/desktop/steelVault/public/javascripts/receiver.js"></script> 

을, 그래서 명시 적으로 removeAttribute() 함수를 참조하는 어떤 코드를 볼 수 없습니다 예제에서 누락 된 일부 코드 또는 일부 스크립트가 제대로로드되지 않는 문제가 있습니다.

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <!-- Omitted --> 
 
</head> 
 
<body> 
 
    <button type="submit" id="passform"></button> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    <script> 
 
    $(function() { 
 
     $("#passform").click(function() { 
 
     alert('hello'); 
 
     console.log('hello'); 
 
     }); 
 
    }); 
 
    </script> 
 
</body> 
 
</html>

+0

시도해 보았습니다. , 여전히 작동하지 않습니다 – Sparksido

+0

jQuery 파일이 실제로 제대로로드되고 있습니까? 브라우저에서 개발자 도구 (F12)를 사용하고 콘솔 또는 네트워크 탭에서 오류가 있는지 확인하십시오. –

+0

그럴 수도 있지만 그 오류를 디코딩하는 방법을 알지 못해서 브라우저 도구에서 오류가 발생했습니다. – Sparksido

0

당신은 크롬에서이 작업을 실행하고 있습니까? AdBlock과 관련 될 수 있습니다. 브라우저를 FireFox로 변경해보고 동일한 오류가 발생하는지 확인하십시오.

관련 문제