get data attribute javascript jquery from select option code example

Example 1: jquery get selected option value

var selectedOptionText = $('#mySelectID').find(":selected").text();//selected option text
var selectedOptionVal = $('#mySelectID').find(":selected").val();//selected option value

Example 2: jquery get option data attribute

$(this).find(':selected').data('id');

Example 3: javascript get data attribute of selected option

function check_status(obj) {
  var uid = obj.options[obj.selectedIndex].getAttribute('data');
  alert(uid);
}