The S object represents an HTML <s> element.
The S object supports the standard properties and events.
We can access a <s> element by using getElementById().
<!DOCTYPE html>
<html>
<body>
<s id="myS">My car is blue.</s>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w w w. j av a 2 s . com-->
var x = document.getElementById("myS");
x.style.color = "blue";
}
</script>
</body>
</html>
The code above is rendered as follows:
We can create a <s> element by using the document.createElement() method.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from w ww.ja v a2 s. c om-->
var x = document.createElement("S");
var t = document.createTextNode("this is a test");
x.appendChild(t);
document.body.appendChild(x);
}
</script>
</body>
</html>
The code above is rendered as follows: