'2018/02/04'에 해당되는 글 1건

728x90


The addClass() method adds one or more class names to the selected elements. (addClass 메소드는 하나 이상의 클래스를 추가할 수 있다)
$(selector).addClass(classname,function(index,currentclass))


위 예제를 실행해보면 addClass 이전과 이후의 현재 Class명을 얻어오도록 되어 있어 클래스가 어떻게 추가되었는지 확인할 수 있다.

Firefox 브라우저 또는 Chrome 브라우저에서 F12키를 누르면 console에서 변하는 결과를 확인할 수 있다.

CSS 클래스를 jQuery addClass 로 동적으로 추가하는 방법이라고 보면 된다.


도움되는 참조 사이트

http://jsfiddle.net/vL8DP/

https://stackoverflow.com/questions/13816730/jquery-add-class-and-remove-all-others




'Web 프로그램 > js, jQuery' 카테고리의 다른 글

Popup Modal with jQuery  (0) 2018.04.12
jQuery animate  (2) 2018.02.14
jQuery all Checked  (0) 2018.01.23
[jQuery] 테이블 다루기 (find)  (0) 2018.01.15
JavaScript 와 jQuery 비교 정리  (0) 2018.01.15
블로그 이미지

Link2Me

,