Practice Exercise for drop down selection using DOM Manipulation
Practice Exercise for drop down selection using DOM Manipulation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test Page</title>
</head>
<body>
<div class="wrapper">
<div id="header">
<h1 class="header-tag" style="text-align:center; color:red;">EXERCISE</h1>
<select id="select-box">
<option value="RUSTIC TRAVEL JUNKIE">RUSTIC TRAVEL JUNKIE</option>
<option value="CODING GURU 99">CODING GURU 99</option>
<option value="TRAVERSY MEDIA">TRAVERSY MEDIA</option>
</select>
<button onclick="box()"> SUBMIT </button>
<script>
function box(){
var a= document.getElementById("select-box");
alert(a.options[a.selectedIndex].value)
}
</script>
</body>
</html>
OUTPUT :
Comments
Post a Comment
I WOULD APPRECIATE IF YOU LEAVE A COMMENT OR YOUR FEEDBACK HERE !!!