Search the Community
Showing results for tags 'I want to do this!'.
-
I want to make this:<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>jQuery(document).ready(function(){function afterText(){var txt1="<b>I </b>"; // Create element with HTMLvar txt2=$("<i></i>").text("love "); // Create with jQueryvar txt3=document.createElement("big"); // Create with DOMtxt3.innerHTML="jQuery!";$("img").after(txt1,txt2,txt3); // Insert new elements after img});});</script></head><body><img src="/images/w3jquery.gif" alt="jQuery" width="100" height="140"><br><br><button onclick="afterText()">Insert after</button></body></html>into a combination of these two:<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>jQuery(document).ready(function (){jQuery("#appendText").click(function(){var txt1="<p>Text.</p>"; // Create text with HTMLvar txt2=$("<p></p>").text("Text."); // Create text with jQueryvar txt3=document.createElement("p");txt3.innerHTML="Text."; // Create text with DOM$("body").append(txt1,txt2,txt3); // Append new elements});});</script></head><body><p>This is a paragraph.</p><button id="appendText">Append text</button></body></html>and:<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script>function afterText(){var txt1="<b>I </b>"; // Create element with HTMLvar txt2=$("<i></i>").text("love "); // Create with jQueryvar txt3=document.createElement("big"); // Create with DOMtxt3.innerHTML="jQuery!";$("img").after(txt1,txt2,txt3); // Insert new elements after img}</script></head><body><img src="/images/w3jquery.gif" alt="jQuery" width="100" height="140"><br><br><button onclick="afterText()">Insert after</button></body></html>