jQuery .addClass()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:53 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

jQuery .addClass()
  • CSS 클래스 추가 함수
  • HTML 요소에 CSS class를 추가하는 jQuery 메소드
$( "h1" ).addClass( "myclass" );
$( "div" ).addClass( "class1 class2" );

2 예시[ | ]

<style>
.highlight { background: yellow; }
</style>

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$(function() {
	$("p").last().addClass( "highlight" );
});
</script>

<p>Hello</p>
<p>and</p>
<p>Goodbye</p>

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}