jQuery – getting custom attribute from selected option

0
575

You’re adding the event handler to the <select> element.
Therefore, $(this) will be the dropdown itself, not the selected <option>.

You need to find the selected <option>, like this:

var option = $('option:selected', this).attr('mytag');

Reference link – https://stackoverflow.com/questions/2230704/jquery-getting-custom-attribute-from-selected-option

LEAVE A REPLY

Please enter your comment!
Please enter your name here