Javascript DOM HTML Bold Object get

Introduction

The Bold object represents an HTML <b> element.

We can access a <b> element by using getElementById():

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  w  w  w  .j av a2 s.c o m*/
  var x = document.getElementById("myB");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related