1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-27 01:25:34 +00:00
elinks/test/ecmascript/assert/element.setAttribute.html
2024-06-01 13:30:03 +02:00

33 lines
749 B
HTML

<!DOCTYPE html>
<html>
<head>
<style>
.democlass {
color: red;
}
</style>
</head>
<body>
<h1>Hello World</h1>
<p>Click the button to add a class attribute with the value of "democlass" to the h1 element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var before = document.getElementsByTagName("H1")[0].outerHTML;
console.assert(before === '<h1>Hello World</h1>', 'H1');
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
var after = document.getElementsByTagName("H1")[0].outerHTML;
console.assert(after === '<h1 class="democlass">Hello World</h1>', 'H1 with class');
}
console.error("element.setAttribute.html");
myFunction();
console.exit();
</script>
</body>
</html>