링크 · http://api.jquery.com/element-selector/



element selector

Element Selector (“element”) - 요소 선택자 (“요소명”)

설명: 주어진 태그의 이름을 가진 모든 요소를 찾습니다.

자바스크립트의 getElementsByTagName() 와 같습니다.


예제: 모든 <div> 요소를 찾습니다.


<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>element demo</title>
  <style>
  div, span {
    width: 60px;
    height: 60px;
    float: left;
    padding: 10px;
    margin: 10px;
    background-color: #eee;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<div>DIV1</div>
<div>DIV2</div>
<span>SPAN</span>

<script>
$( "div" ).css( "border", "9px solid red" );
// 코스 해설 모든 <div> 요소를 찾아 빨간선으로 표시합니다.
</script>

</body>
</html>


'!' 카테고리의 다른 글

[jQuery]:Multiple Selector ("selector1, selector2, selector3 ")  (0) 2018.04.15
[jQuery]:ID Selector ("#id")  (0) 2018.04.15
[jQuery]:Class Selector(".class name")  (0) 2018.04.15
[jQuery]:All Selector ("*")  (0) 2018.04.15
[jQuery]:animated Selector  (0) 2018.04.01

+ Recent posts