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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 139
    Comment on it

    This method is used to change the content of the elements . It change only selected elements .It can also replaces the selected content with new content.It doesn't take any arguments.
    Syntax :

    $(selector).html() 
    

    Return content :

    $(selector).html(content) // It return the content of the all matched elements
    

    Set Content :

    $(selector).html(function(index, currentcontent)) // It is used to overwrites the content of all the matched elements
    

    Example :
    HTML Code :

    <html>
    <head></head>
    <body>
    <button>Click here to see the change of selected contents of matched elements</button>
    <p>It will change after click on button</p>
    </body>
    </html>
    

    jQuery Code :

    $(funtion(){
    $("button").click(function(){
    $("p").html("Hello<b>Mukesh</b>")
    });
    });
    

    Output :
    Before jQuery :

    It will change after click on button
    

    After jQuery :

    Hello Mukesh // Content of p has been changed
    

 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: