- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get a DOM Element from a jQuery Selector?
To get a DOM Element from a jQuery Selector, use the $('#element').get(0). This returns the DOM element.
Example
You can try to run the following code to learn how to get a DOM Element from a jQuery Selector. For our checkbox example, get a DOM element like the following code:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(":checkbox").click(function() { if ($(this).is(":checked")) { alert("Checkbox checked!"); } }); }); </script> </head> <body> <input type="checkbox" id="demo" /> </body> </html>
- Related Articles
- How to exclude first and second element from jQuery selector?
- jQuery element Selector
- jQuery element ~ siblings Selector
- jQuery element + next Selector
- How to remove an element from DOM using jQuery?
- How to combine a class selector and an attribute selector with jQuery?
- How can I get the ID of an DOM element using jQuery?
- How to replace a DOM element with the specified HTML or DOM elements using jQuery?
- How to get the children of the $(this) selector in jQuery?
- How to remove all the elements from DOM using element ID in jQuery?
- How to get the width of a div element using jQuery?
- How to get the height of a div element using jQuery?
- How to pass a variable into a jQuery attribute-contains selector?
- How to insert an element into DOM using jQuery?
- How to get the closest input value from clicked element with jQuery?

Advertisements