- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 the value of div content using jQuery?
To get the value of div content in jQuery, use the text() method. The text( ) method gets the combined text contents of all matched elements. This method works for both on XML and XHTML documents.
Example
You can try to run the following code to get the value of div content using jQuery:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#button1").click(function() { var res = $('#demo').text(); alert(res); }); }); </script> </head> <body> <div id="demo"> This is <b>demo</b> text. </div> <button id="button1">Get</button> </body> </html>
- Related Articles
- How to print div content using jQuery?
- How to copy the content of a div into another div using jQuery?
- How to get the content of a textarea using 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 get innerHTML of a div tag using jQuery?
- How to get HTML content of an element using jQuery?
- How to clear the content of a div using JavaScript?
- How to get content of div which contains JavaScript script blocks?
- How to replace the content of an element using jQuery?
- How to set the content of a textarea using jQuery?
- How to duplicate a div using jQuery?
- How to create div dynamically using jQuery?
- How to replace innerHTML of a div using jQuery?
- How to get the input value of the first matched element using jQuery?

Advertisements