본문 바로가기
프로그램

jQuery parent() Method

by 바람사이 2021. 12. 31.

The parent() method returns the direct parent element of the selected element.

(parent() 메서드는 선택한 요소의 직접적인 부모 요소를 반환합니다.)

 

 

 

html

<div>
	<h3>Hello</h3>
	<div class="d1">
		<p class="p1">
			Lorem Ipsum Dolor
		</p>
	</div>
</div>

 

 

css

.color {
	color:red;
	font-size:2em;
	font-weight:bold;
}

 

 

Jquery

$( '.p1' ).parent( 'div.d1' ).css( 'font-size', '2em');
$( '.p1' ).parent().siblings('h3').addClass('color');

 

Result(결과)

 

반응형

'프로그램' 카테고리의 다른 글

jQuery parents() Method  (0) 2022.01.12
jQuery hover() Method  (0) 2022.01.08
jQuery siblings() Method  (0) 2021.12.31
jQuery find() Method  (0) 2021.12.31
alert message box(간단한 경고 메세지 박스)  (0) 2021.12.30

댓글