Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery prepend ( ) Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 117
    Comment on it

    This method is used to insert the data at the beginning of the selected elements . It is just opposite of the append( ) method . Append ( ) method is used to insert the data at the end of selected elements .
    Syntax :

    $(selector).prepend(content,function(index,html))
    

    Example :
    HTML Code :

    <html>
    <head></head>
    <body>
    <button id="button1">After click ,Data added at the beginning of  p tag</button>
    <p>Hello Mukesh Tomar</p>
    <p>From Meerut</p>
    </body>
    </html>
    

    jQuery Code :

    $(funtion(){
    $("#button1").click(function(){
    $("p").prepend("<b>I have added at the beginning of  p tag</b>");
    });
    });
    

    Output :

    I have added at the beginning of p tag.Hello Mukesh Tomar

    I have added at the beginning of p tag .From Meerut

 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: