Create an Underline Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Underline

Introduction

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create a U element with some text</button>

<script>
function myFunction() {/*w w w .j  ava  2s.c om*/
    var x = document.createElement("U");
    var t = document.createTextNode("This text is underlined");
    x.appendChild(t);
    document.body.appendChild(x);
}
</script>

</body>
</html>

Related Tutorials