![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 use jQuery.toggle() method in jQuery?
The toggle() method toggles displaying each of the set of matched elements.
Example
You can try to run the following code to learn how to work with jQuery.toggle() method:
<html> <head> <title>jQuery toggle() method</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("#toggle").click(function(){ $(".target").toggle( ); }); }); </script> <style> p { background-color:#bca; width:200px; border:1px solid green; } </style> </head> <body> <p>Click on the following button:</p> <button id = "toggle"> Toggle </button> <div class = "target"> <img src = "../images/jquery.jpg" alt = "jQuery" /> </div> </body> </html>
Advertisements