Skip to main content
Skip table of contents

elementCount

Counts the number of elements having a given selector. Places the result into a new variable.

var

String

Defines the name of the variable that will receive the number of elements having a given selector as a Number value.

selector

String

Defines the name of the tag, id or class to search for.

If selector starts with:

  • #, it targets the id of an element

  • ., it targets the class of an element

Otherwise the selector targets a tag of an element in HTML.

value

File, String

Defines the content this command will be inspecting.

Let's take a look at the example below. There are total of three elements that includes the class first.

CODE
  <div class="document">
    <div class="round">
      <div class="round first">
        <p class="first rectangle"></p>
        <div class="first">
          <p>Hello</p>
        </div>
      </div>
    </div>
  </div>

The number of those elements is stored in "count" variable within this example.

CODE
<elementCount var="count" selector=".first" value="${file}" />
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.