---
title: "jQuery onclick toggle class"  
description: "jQuery onclick toggle class"  
author: "Anonymous User"  
published: 2018-04-05  
updated: 2018-06-18  
canonical: https://www.mindstick.com/forum/34463/jquery-onclick-toggle-class  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# jQuery onclick toggle class

How do I use toogle in this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)

```
<body>
<h1>Hello</h1>
<p>Hi</p>
<button>Toggle</button>
</body>
```

## Replies

### Reply by Arti Mishra

You can use below code for toggle class:

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").toggle();
      //   $("h1").toggle();    });
});
</script>
```

\


---

Original Source: https://www.mindstick.com/forum/34463/jquery-onclick-toggle-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
