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