IT & 일상기록/JQuery
[JQuery] jquery.js 파일 - addClass 함수
확고
2022. 4. 1. 19:32
※ jquery.js 파일 안에 있는 addClass 함수 정의해 있는 걸 가져다가 사용하므로 js 파일 추가 및 위치 설정 필요
<script type="text/javascript" src="./../js/jquery.js"/>
함수 구분 | 설명 | 사용 예시 |
객체.addClass('클래스명'); | 객체에 클래스를 추가 | ① $('div').addClass('exam'); → div 태그 자리에 exam 클래스를 추가해라 (div 태그 자리에 직접 class="exam" 쓴 것과 같음) ② $('#exam1').addClass('hwakgo'); → id가 exam1인 곳에 hwakgo 클래스를 추가해라 ※ id를 불러올 땐 #을 사용 ③ $('.exam2').addClass('gogo'); → class가 exam2인 곳에 gogo 클래스를 하나 더 추가 ※ class를 불러올 땐 점(.)을 사용 |
▼ js 파일 다운로드하는 사이트(https://jquery.com/)
jQuery
What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
jquery.com
728x90
반응형