JavaScript 를 사용하다 이런 오류가 발생 했습니다.
Uncaught ReferenceError: $ is not defined
jQuery 라이브러리를 삽입하지 않고 태그했지 때문에 $기호를 찾을수 없다. 라고 오류를 내고 있습니다.
웹 개발시에 JavaScript 를 쓰게 되면 jQuery 라이브러리를 삽입하지 않은 채 무심코 쓰게 되는 경우가 있는데요.
워낙 jQuery를 많이 사용하기 때문에 까먹게되는거 같습니다.
jQuery는 HTML 문서의 요소를 선택하고 조작하기 위한 JavaScript 라이브러리입니다. jQuery는 강력한 선택자와 다양한 기능을 제공하여 웹 개발자들이 JavaScript를 좀 더 쉽게 작성할 수 있게 도와줍니다.
jQuery 라이브러리가 삽입되어 있는지 확인하시고 jQuery 라이브러리가 없는 경우
이 오류를 해결하기 위해서 두가지 방법을 사용 할수 있는데
1. jQuery 라이브러리를 다운받아 파일로 저장해두고 사용하는 경우
Download jQuery | jQuery
link Downloading jQuery Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download
jquery.com
jQuery CDN
The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking. This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libr
releases.jquery.com
2. 최신 jQuery를 제공해주는 링크 이용
//code.jquery.com/jquery-latest.min.js
<script src="//code.jquery.com/jquery-latest.min.js"></script>
원하는 방식으로 사용하면 되고..
저는 주로 2번째 방식을 사용하는데 링크가 바뀌게 될 경우 경로를 전체적으로 수정해줘야하는 단점이 있습니다.
개발하는 환경에 맞춰 사용하시면 될거같습니다.
이렇게 Uncaught ReferenceError: $ is not defined.. 오류는 간단하게 해결 되었습니다.^^;;
'개발자이야기' 카테고리의 다른 글
레지스트리 오류 복구 (0) | 2023.10.25 |
---|---|
ERR_SSL_PROTOCOL_ERROR (0) | 2023.10.15 |
구글 서치콘솔 '크롤링됨 - 현재 색인이 생성되지 않음' (0) | 2023.09.19 |
[JAVA 자바] split() 문자열 자르기 (0) | 2023.09.05 |
SVN 히스토리 (0) | 2023.07.23 |