목차

jQuery multiple element Selector

  • description : jQuery multiple element Selector
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2021-06-02


The source of this article

jQuery multiple element Selector

Example

모든 <h2>, <div>, <span> 요소들을 선택합니다.

<body>
  <h1>Welcome to My Homepage</h1>
  <h2>Nice to meet you</h2> <!-- selected & changed -->
 
  <div>Very nice indeed</div> <!-- selected & changed -->
 
  <p>How are you?</p>
  <p>I'm fine, <span>thanks.</span></p> 
  <!-- only span selected & changed -->
 
  <script>
    $(document).ready(function () {
      $("h2, div, span").css({
        color: "white",
        fontWeight: "bold",
        backgroundColor: "royalblue",
        textDecoration: "underline"
      });
    });
  </script>
 
</body>  

Definition and Usage

요소 선택자는 다수의 요소들을 선택하는 데에 사용될 수 있습니다.

Note: 각각의 요소를 콤마(,)로 구분합니다.

Syntax

$("element1, element2, element3,...")
Parameter Description
element 필수입니다. 선택할 요소를 지정합니다.


문서(document)에서 모든 요소들을 선택하기 위해 * 선택자를 사용합니다.