๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ”ฅ TIL

[HTML] label ํƒœ๊ทธ / [jQuery] childern() , find()

๋ฐ˜์‘ํ˜•

label ํƒœ๊ทธ

  • <label> ํƒœ๊ทธ ์•ˆ์—๋Š” <div> , <p> ํƒœ๊ทธ๊ฐ€ ๋“ค์–ด๊ฐ€๋ฉด ์•ˆ๋œ๋‹ค.

 

children() / find()

<h1>.children() ๋ฉ”์†Œ๋“œ</h1>
<div class="container">
  <div>div(ํ• ์•„๋ฒ„์ง€)
    <ul class="child">ul(๋ถ€๋ชจ)
      <li>li(์ž์‹)
        <span>span(์†์ž1)</span>
        <span>span(์†์ž2)</span>        
      </li>
    </ul>
  </div>
</div>

<h1>.find() ๋ฉ”์†Œ๋“œ</h1>
<div class="container">
  <div>div(ํ• ์•„๋ฒ„์ง€)
    <ul class="find">ul(๋ถ€๋ชจ)
      <li>li(์ž์‹)
        <span>span(์†์ž1)</span>
        <span>span(์†์ž2)</span>        
      </li>
    </ul>
  </div>
</div>
.container * {
  display: block;
  border: 1px solid lightgrey;
  color: lightgrey;
  padding: 5px; margin: 15px;
}
$(function() {
  // 1. children()
  $('ul.child').childern('*').css({border: '2px solid red'});
  // 2. find()
  $('ul.find').find('*').css({border: '2px solid blue'});
});

childern()

  • li(์ž์‹)๋งŒ ๋ณ€ํ™”ํ•œ๋‹ค.

find()

  • li(์ž์‹)๊ณผ span(์ž์‹1), span(์ž์‹2)์ด ๋ณ€ํ™”ํ•œ๋‹ค.

Reference

ํ•˜์œ„์š”์†Œ์˜ ํƒ์ƒ‰.children() .find()
๋ฐ˜์‘ํ˜•

'๐Ÿ”ฅ TIL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

2021.04.07 // width calc() ์ฃผ๊ธฐ  (0) 2021.04.07
2021.04.05  (0) 2021.04.05
2021.03.22  (0) 2021.03.22
[CSS] ์†์„ฑ ์„ ํƒ์ž ์ •๋ฆฌ  (0) 2021.03.19
[CSS] ํ˜•์ œ์š”์†Œ๋กœ ๊ฐฏ์ˆ˜ ์•Œ์•„๋‚ด๊ธฐ  (0) 2021.03.18