Javascript examples for DOM HTML Element:Span
You can create a <span> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a SPAN element</button> <script> function myFunction() {/* w w w . j a v a2s. co m*/ var x = document.createElement("SPAN"); var t = document.createTextNode("This is a span element."); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>