ドキュメント

Selectors/element

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Selectors

element

Matches all elements with the given tag name.
Arguments:
elementString
An element to search for. Refers to the tagName of DOM nodes.
Examples:

Finds every DIV element.

$("div").css("border","9px solid red");

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    $("div").css("border","9px solid red");
  });
  </script>
  <style>
  div,span {
    width: 60px;
    height: 60px;
    float:left;
    padding: 10px;
    margin: 10px;
    background-color: #EEEEEE;
  }
  </style>
</head>
<body>
  <div>DIV1</div>
  <div>DIV2</div>
  <span>SPAN</span>
</body>
</html>

NameType