How to get dropdown selected value in jQuery by class

In this article, you will learn how to get selected value of dropdown in jQuery by class attribute.

Demo : get selected value of dropdown using class.
<select class="my-element">
  <option>Drop down 1</option>
  <option>Drop down 2</option>
  <option>Drop down 3</option>
  <option>Drop down 4</option>
</select>
<script>
$(".my-element").change(function(){
  let myValue = $(this).val();
  alert(myValue);
})
</script>
Try it Yourself »