Javascript DOM HTML S Object get

Introduction

The S object represents an HTML <s> element.

We can access a <s> element via document.getElementById():

var x = document.getElementById("myS");

Click the button to set the color of <S> element to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p><s id="myS">This is a test.</s></p>
<p>This is a test.</p>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w ww.  j  a  va  2  s. co m*/
  var x = document.getElementById("myS");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related