---
title: "Why are use the after and insertAfter method in JQuery?"  
description: "Why are use the after and insertAfter method in JQuery?"  
author: "Ethan Karla"  
published: 2021-07-28  
canonical: https://answers.mindstick.com/qa/93806/why-are-use-the-after-and-insertafter-method-in-jquery  
category: "web application"  
tags: ["web development", "web application development"]  
reading_time: 1 minute  

---

# Why are use the after and insertAfter method in JQuery?

Why are use the after and insertAfter [method in JQuery](https://www.mindstick.com/forum/156670/has-method-in-jquery)?

## Answers

### Answer by Ravi Vishwakarma

we use after() [method](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) to add data in html page, this data is added after selected elements and if we use after insert() then data is added after selected elements but before() method after() Insert data after method as a child.

```
After $(selector).after (content) $(selector).after (content, function (index))
insertAfter $(content).insertAfter(content)
```

```
<!DOCTYPE html><html><head><script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script><script>$(document).ready(function(){  $('button').click(function(){    $('p').after('<p><b>Hello world! by after() </b></p>');    $('<p><b>Hello world! by insertAfter() </b></p>').insertAfter('p');  });});</script></head><body><button>Insert content by before() and prepend()</button><p>This is a paragraph.</p></body></html>
```

Output:

![Why are use the after and insertAfter method in JQuery?](https://answers.mindstick.com/questionanswer/86b46720-f30f-47a8-a711-58ddeb01d83b/images/b82050d4-d1d9-46d8-aea9-e0bd10ee3719.png)

\


---

Original Source: https://answers.mindstick.com/qa/93806/why-are-use-the-after-and-insertafter-method-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
