jQuery Misc





Retrieve the value of a data attribute for the first element in the set of matched elements.



Iterate over a jQuery object, executing a function for each matched element.

$("li").each(function(index, element) {  // Your code here});


Retrieve the DOM elements matched by the jQuery object as an array.

var elements = $("p").get();


Search for a given element from among the matched elements and returns its index.

var index = $("#item").index();


Relinquish jQuery's control of the `$` variable.

var jq = $.noConflict();


Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.

var queryString = $.param({ key1: "value1", key2: "value2" });


Remove a previously-stored piece of data.



Return the number of elements in the jQuery object.

var count = $("div").size();


Retrieve all the DOM elements contained in the jQuery set as an array.

var elementsArray = $("p").toArray();


<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>jQuery Utility Methods Example</title>
  <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    div {
      padding: 10px;
      margin: 5px;
      border: 1px solid #ccc;

<div id="exampleElement" data-info="Sample Data">This is an example element.</div>

  // Using data() method to retrieve and set data
  var infoData = $("#exampleElement").data("info");
  console.log("Data retrieved using data():", infoData);

  // Using each() method to iterate over elements
  $("div").each(function(index, element) {
    console.log("Element at index", index, ":", element);

  // Using get() method to retrieve DOM elements as an array
  var elementsArray = $("div").get();
  console.log("Array of DOM elements:", elementsArray);

  // Using index() method to get the index of an element
  var elementIndex = $("#exampleElement").index("div");
  console.log("Index of #exampleElement among div elements:", elementIndex);

  // Using $.noConflict() to release the $ variable
  var jq = $.noConflict();
  jq(document).ready(function() {
    jq("div").css("background-color", "lightyellow");

  // Using $.param() to serialize data for URL query string
  var params = { name: "John", age: 30, city: "New York" };
  var queryString = $.param(params);
  console.log("Serialized URL query string:", queryString);

  // Using removeData() to remove stored data

  // Using size() to get the number of matched elements
  var elementSize = $("div").size();
  console.log("Number of div elements:", elementSize);

  // Using toArray() to convert the set of matched elements to an array
  var elementsAsArray = $("div").toArray();
  console.log("Matched elements as an array:", elementsAsArray);


Quick Recap - Topics Covered

jQuery Misc

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.

Example js

Example 1 Example 2 Example 3 Example 4 Example 5