We can create a <samp> element via the document.createElement()
method:
var x = document.createElement("SAMP");
Click the button to create a SAMP element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {// w w w. j a v a2 s. c om var x = document.createElement("SAMP"); var t = document.createTextNode("this is a test"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>