Get Samp Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Samp

Introduction

The Samp object represents an HTML <samp> element.

You can access a <samp> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<samp id="mySamp">Sample output from a computer program</samp>

<button onclick="myFunction()">set the color of  samp element</button>

<script>
function myFunction() {/*w w w  .j  a  v  a  2  s  . c  o m*/
    var x = document.getElementById("mySamp");
    x.style.color = "red";
}
</script>

</body>
</html>

Related Tutorials