Get Attribute Value of the Selected Option
1) For Example if your select tag is this
<select id=”yourid”>
<option value=”a” myTag=”111″>My option</option>
<option value=”b” myTag=”222″>My other option</option>
</select>
2) Then you will get your attribute value
$(function() {
$(“#yourid”).change(function(){
var getelement = $(this).find(‘option:selected’);
var myTag = getelement .attr(“myTag”);
alert(myTag)
});
});
3) Do not forget to include cdn link of jquery
<script src=”jquery-3.6.1.min.js”></script>
for more information click here. you are reading this article on knowledge mirror, for more such articles click here.