Create an Abbreviation Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Abbreviation


You can create an <abbr> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="myP"></p>

function myFunction() {/* w w w .  j  a  v  a  2s .c  o  m*/
    var x = document.createElement("ABBR");
    var t = document.createTextNode("abbr text");
    x.setAttribute("title", "title of abbr");


Related Tutorials