We can create an <i> element via the document.createElement()
method:
var x = document.createElement("I");
Click the button to create an I element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w ww . j ava2 s . co m*/ var x = document.createElement("I"); var t = document.createTextNode("Some italic text"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>