How to convert jQuery to JavaScript ?
Last Updated :
12 Jul, 2025
JavaScript is an object orient programming language designed to make web development easier and more attractive. In most cases, JavaScript is used to create responsive, interactive elements for web pages, enhancing the user experience.
jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript.
Selection: In jQuery, to select any element, we simply use the
$() sign, but in JavaScript, to select any element, we can use
querySelector() or
querySelectorAll().
- Program:
javascript
// jQuery to select all instances
// of class "select"
$(".select");
// JavaScript to select only the
// first instance of class "select"
document.querySelector(".select");
// To select all the instances
// of class "select"
document.querySelectorAll(".select");
Some other examples of selectors:
To select the entire html:
To select the entire html body:
- In jQuery:
$("body")
- In JavaScript:
document.body
Class manipulation:
- Program:
javascript
// To add a class "class-name" to a <p> tag
// jQuery:
$p.addClass(class-name)
// JavaScript:
p.classList.add(class-name)
Below some other examples of manipulation:
To add a class to an html element:
To remove a class to an html element:
To toggle a class to an html element:
To check whether an html element contains a class:
Event Listeners
- Program:
javascript
// To add an event on button click
// jQuery:
/* handle click event */
$(".button").click( function(event) {
});
// JavaScript:
/* handle click event */
document.querySelector(".button")
.addEventListener("click", (event) => {
});
CSS Styling:
- Program:
javascript
// To give a margin of 10px to all the div
// jQuery:
$div.css({ margin: "10px" })
// JavaScript:
div.style.margin= "10px"
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it's philosophy of “Write less, do more".
You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
Similar Reads
How to trigger events in JavaScript ? JavaScript is a high-level, interpreted, dynamically typed client-side scripting language. While HTML is static and defines the structure of a web page, JavaScript adds interactivity and functionality to HTML elements. This interaction is facilitated through events, which are actions or occurrences
2 min read
How to use jQuery getScript ? The jQuery .getScript() method loads a JavaScript file from a server using the GET HTTP method and then executes it. Syntax: $.getScript(url,[callback]) Let us look at an example to understand how this method works. Example: In this example, we will use a URL to load the JavaScript file 'color.js' f
1 min read
Difference Between JavaScript and jQuery JavaScript is a programming language used for web development, while jQuery is a library written in JavaScript, simplifying tasks like DOM manipulation, event handling, and AJAX requests, making JavaScript code more concise and readable. JavaScriptJavaScript is a crucial scripting language for enhan
6 min read
Difference Between JavaScript and jQuery JavaScript is a programming language used for web development, while jQuery is a library written in JavaScript, simplifying tasks like DOM manipulation, event handling, and AJAX requests, making JavaScript code more concise and readable. JavaScriptJavaScript is a crucial scripting language for enhan
6 min read
JavaScript Course What is JavaScript ? JavaScript is a very famous programming language that was originally started in the year of 1995 with the motive of making web pages alive. It is also an essential part of the web developer skillset. In simple terms, if you want to learn web development then learn HTML & CSS before starting JavaScri
3 min read
JavaScript Course What is JavaScript ? JavaScript is a very famous programming language that was originally started in the year of 1995 with the motive of making web pages alive. It is also an essential part of the web developer skillset. In simple terms, if you want to learn web development then learn HTML & CSS before starting JavaScri
3 min read