Javascript DOM HTML Aside Object get

Introduction

The Aside object represents an HTML <aside> element.

We can access an <aside> element by using getElementById():

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

Click the button to set the text color of the aside content to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p>"this is a test. this is a test. this is a test. this is a test. 
this is a test. this is a test. this is a test. "</p>

<aside id="myAside">
  <h4>Test</h4>
  <p>The test is just a test. The test is just a test. The test is just a test. 
  The test is just a test. The test is just a test. The test is just a test.</p>
</aside>/*from   w w  w .  ja v a2 s  .  c o m*/

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
  var x = document.getElementById("myAside");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related