The Aside
object represents an HTML <aside>
element.
The following code accesses an <aside>
element by
using getElementById()
:
<!DOCTYPE html>
<html>
<body>
<aside id="myAside">
<h1>header</h1>
<p>this is a test.</p>
</aside><!-- ww w. j a v a2 s . com-->
<aside id="myAnohterAside">
<h1>header 1</h1>
<p>this is a test.</p>
</aside>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("myAside");
x.style.color = "blue";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code creates an <aside>
element
by using the document.createElement()
method:
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- www.ja v a 2 s . c o m-->
var x = document.createElement("ASIDE");
x.setAttribute("id", "myAside");
document.body.appendChild(x);
var heading = document.createElement("H1");
var txt1 = document.createTextNode("Hi from h1");
heading.appendChild(txt1);
document.getElementById("myAside").appendChild(heading);
}
</script>
</body>
</html>
The code above is rendered as follows:
The Aside object supports the standard properties and events.