본문 바로가기
JS/jQuery

.first() //제이쿼리(jQuery)

by 싸공 2020. 8. 1.
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>first demo</title>
  <style>
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<div>
    <p> Hello jQuery!! 1</p>
    <p> Hello jQuery!! 2</p>
    <p> Hello jQuery!! 3</p>
    <p> Hello jQuery!! 4</p>
</div>
 
<script>
$"div p" ).first().css('background-color''yellow');
</script>
 
</body>
</html>



.first() 메소드는 첫 번째 요소를 선택한다.


'JS > jQuery' 카테고리의 다른 글

.addClass() //제이쿼리(jQuery)  (0) 2020.08.01
.find() //제이쿼리(jQuery)  (0) 2020.08.01