jQuery API

Element Selector (“element”)

element selector

version added: 1.0jQuery('element')

  • element
    An element to search for. Refers to the tagName of DOM nodes.

Description: Selects all elements with the given tag name.

JavaScript's getElementsByTagName() function is called to return the appropriate elements when this expression is used.

Example:

Finds every DIV element.

<!DOCTYPE html>
<html>
<head>
  <style>
  div,span {
    width: 60px;
    height: 60px;
    float:left;
    padding: 10px;
    margin: 10px;
    background-color: #EEEEEE;
  }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div>DIV1</div>

  <div>DIV2</div>
  <span>SPAN</span>
<script>$("div").css("border","9px solid red");</script>

</body>
</html>

Demo:

Support and Contributions

Need help with Element Selector (“element”) or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to Element Selector (“element”)? Report it to the jQuery core team.

Found a problem with this documentation? Report it on the GitHub issue tracker

  • Adrian

    whats the selector $(“element”, object); ?
    what is “object”, its not listen on the “Selector dokumentation”.

  • Alex

    Sometimes we have something like this:
    <someclass:div> … </someclass:div> … then later we may have …
    <someclass:span> … </someclass:span>
    How can we select “someClass” and match both <someclass:div> and <someclass:span> ?

    Thanks,
    Alex</someclass:span></someclass:div>

    • Alex

      … and i mean it as a general rule, not only for the 2 tags div and span. Btw looks like disqus has a little bug there it has closed the tags for me … nice :)

      • http://www.learningjquery.com/ Karl Swedberg

        Please direct this question to the appropriate forum at http://forum.jquery.com/
        You'll have a much better chance of having the questions answered there.

        Thanks for understanding.

  • Jbp1107953

    i want to select only input type=text