You need to first connect the jquery.min.js link.
<script src=”https://code.jquery.com/jquery-1.12.4.min.js”></script>
To alert selected value using jquery, you need to follow this code:
Dropdown Field:
<div> <label>Select Category:</label> <select class="category"> <option value="Two Wheel">Two Wheel</option> <option value="Three Wheel">Three Wheel</option> </select> </div>
jQuery:
<script type="text/javascript"> $(document).ready(function() { $("select.category").change(function() { var selectedCategory = $(".category option:selected").text(); if (selectedCategory == "Two Wheel") { alert("You have selected the category - Two Wheel"); } else if (selectedCategory == "Three Wheel") { alert("You have selected the category - Three Wheel"); } }); }); </script>
Question and answer is powered by AnsPress.io