---
title: "How to Slidetoggle next element in jquery?"  
description: "How to Slidetoggle next element in jquery?"  
author: "Anonymous User"  
published: 2014-11-23  
updated: 2014-11-24  
canonical: https://www.mindstick.com/forum/12678/how-to-slidetoggle-next-element-in-jquery  
category: "jquery"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# How to Slidetoggle next element in jquery?

I have many snippets with a "read more" [link](https://www.mindstick.com/articles/23633/link-builder), and I'm looking for a way to have the same [selectors](https://www.mindstick.com/interview/22831/what-is-the-use-of-selectors-in-objective-c) for all the snippets. I thought that jQuery's next could work:

```
<script>$(document).ready(function () {    $(".readmore").click(function
() {        $(".readmore").next().slideToggle("slow",
function () {            $(window).scrollTop($(this).offset().top);        });    });});</script>Visible text 1<a class="readmore">Read More
1</a><div class="more">Text to appear 1</div>Visible text 2<a class="readmore">Read More
2</a><div class="more">Text to appear 2</div>Visible text 3<a class="readmore">Read More
3</a><div class="more">Text to appear 3</div><style>.more {display:none}</style>
```

Unfortunately, [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) for all snippets appears when clicking on one "read more" link, [instead of](https://www.mindstick.com/articles/330/triggers-in-sql-server) just the next element. What's [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) with the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) above?

## Replies

### Reply by Anonymous User

You should change

```
$(".readmore").click(function () {    $(".readmore").next()...to$(".readmore").click(function () {    $(this).next()...
```

so the next() selector in the click() event function is only applied to the currently clicked element instead of all elements with the class readmore at the same time.


---

Original Source: https://www.mindstick.com/forum/12678/how-to-slidetoggle-next-element-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
