1
0
Fork 0

[js] test case for getElementsByTagName

This commit is contained in:
Witold Filipczyk 2022-12-21 15:33:07 +01:00
parent 216b6021f8
commit 7a1c315522
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<body id="body">
First Name: <input name="fname" type="text" value="Michael"><br>
First Name: <input name="fname" type="text" value="Doug">
<p>Click the button to get the tag name of the first element in the body that has tag P.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById('body').getElementsByTagName("P").item(1).outerHTML;
window.alert(x);
}
</script>
</body>
</html>