jQuery - Multiple Elements Selector



This Multiple Elements selector selects the combined results of all the specified selectors E, F or G.

You can specify any number of selectors to combine into a single result. Here order of the DOM elements in the jQuery object aren't necessarily identical.


Here is the simple syntax to use this selector:

 $('E, F, G,....')


Here is the description of all the parameters used by this selector:

  • E: Any valid selector

  • F: Any valid selector

  • G: Any valid selector

  • ....


Like any other jQuery selector, this selector also returns an array filled with the found elements.


  • $('div, p'): selects all the elements matched by div or p.

  • $('p strong, .myclass'): selects all elements matched by strong that are descendants of an element matched by p as well as all elements that have a class of myclass.

  • $('p strong, #myid'): selects a single elements matched by strong that is descendant of an element matched by p as well as element whose id is myid.

Following example would select elements with class ID big and element with ID div3 and will apply yellow color to its background:

<title>The Selecter Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
<script type="text/javascript" language="javascript">

  $(document).ready(function() {
      $(".big, #div3").css("background-color", "yellow");


<div class="big" id="div1">
  <p>This is first division of the DOM.</p>

<div class="medium" id="div2">
  <p>This is second division of the DOM.</p>

<div class="small" id="div3">
  <p>This is third division of the DOM</p>


This will produce following result: