Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use after() method in JQuery?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 58
    Comment on it

    after():

    • In JQuery, after() method is used to insert the data or content at the end as sibling of the element specify by the parameter.
    • Syntax:
    $(selector).after(content,function(index,html))
    

    Here, we have passed two parameters in the method:

    • The first one is the content which is a required field with values such as HTML elements, jQuery objects and DOM elements.

    • The second one is the function(index,html) which is a optional field. It returns the content to insert.

    • Example: Suppose we have the following HTML code
    <div class='a'> 
      <div class='b'>b</div>
    </div>
    

    Suppose we want to insert div c as the sibling of div a. For this we will use after() method.

    $("div.a").after("<div class='c'>C</div>");
    

    The HTML code now look like

    <div class='a'>
      <div class='b'>b
    </div>
     <div class='c'>C /<div>----this will be placed here.
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: