Add HTML element, jQuery DOM and Javascript DOM - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:after

Description

Add HTML element, jQuery DOM and Javascript DOM

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function afterText() {/*from   www  .ja v a  2 s  .  com*/
    var txt1 = "<b>plain html</b>";                   // Create element with HTML
    var txt2 = $("<i></i>").text("jQuery DOM");    // Create with jQuery
    var txt3 = document.createElement("B");   // Create with DOM
    txt3.innerHTML = "Javascript DOM!";
    $("img").after(txt1, txt2, txt3);      // Insert new elements after img
}
</script>
</head>
<body>

<img src="http://java2s.com/resources/a.png" alt="jQuery" width="100" height="140">

<button onclick="afterText()">Insert after</button>

</body>
</html>

Related Tutorials