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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 186
    Comment on it

    We can add html dynamically to our website using jQuery.

    We use to add html dynamically like when we want on some click function or we want to some other event to add boxes and any other thing.

    We can use function to add

    function appendText() {
        var txt1 = "<p>Text.</p>";               // Create element with HTML 
        var txt2 = $("<p></p>").text("Text.");   // Create with jQuery
        var txt3 = document.createElement("p");  // Create with DOM
        txt3.innerHTML = "Text.";
        $("p").append(txt1, txt2, txt3);         // Append the new elements
    }

    We can also use before() and after() to append or remove before or after something.

    This can be used to remove the html

    function removeText() {
        txt3.innerHTML = "Text.";
        $("p").remove(txt1, txt2, txt3);         // remove the elements
    }

     

 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: