kkkkk1023 2023. 7. 13. 12:45

JavaScript를 작성하다 보니 너무 길고 더럽다는 생각을 많이 해서 HTML을 조작하는 문법을 쉽게 바꿔주는 라이브러리들이 생겼다. 

그게 바로 jQuery, React, Vue가 있다. 이중에서 jQuery를 배워보려고 한다.

 

1. jQuery 설치

 

https://releases.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

[설치 순서]

1. 사이트 접속하기
2.사용하려는 jQuery 버전 선택하기
3. 해당 버전의 minified 클릭하기
4. 해당 코드 복사해서 body 하단에 붙여넣기
5. 붙여넣은 곳 아래에 jQuery 문법 작성하기

 

 

2. jQuery 사용하기

 

// jQuery 사용 전
document.querySelector('.hello').innerHTML = '바보';

// jQuery 사용 후
$('.hello').html('바보');

 

// jQuery 사용 전
document.querySelector('.hello').style.color = 'red';

// jQuery 사용 후
$('.hello').css('color','red');

 

 

3. jQuery 문법 정리

 

https://soft91.tistory.com/9

 

JQuery - JQuery 기본문법

직접 선택자 종류 사용법 설명 전체 선택자 $("*") 모든 요소를 선택 아이디 선택자 $("#아이디 명") id 속성에 지정한 값을 가진 요소를 선택 클래스 선택자 $(".클래스 명") 클래스 속성에 지정한 값

soft91.tistory.com