We can create an <abbr> element by using the document.createElement()
method:
var x = document.createElement("ABBR");
Click the button to create an ABBR element containing the abbreviation "CSS".
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="myP"></p> <script> function myFunction() {//from w ww . ja va 2 s. c o m var x = document.createElement("ABBR"); var t = document.createTextNode("CSS"); x.setAttribute("title", "Cascading Style Sheets"); x.appendChild(t); document.getElementById("myP").appendChild(x); } </script> </body> </html>