I have a select option dropdown like:
<select name="futsalSelect" id="futsalSelect" class="form-control">
<option data-timezone="MST" value="1" selected="">Sample futsal One</option>
<option data-timezone="EST" value="3">Sample futsal Three</option>
</select>
Now, I want to retrive that data-timezone value whenever I change that select option.
So, I tried with:
$("#futsalSelect").change(function() {
futsal_id = $(this).val();
timezone = $(this).attr("data-timezone");
console.log(timezone); //undefined
$("#futsalTimezone").text(timezone);
});
But, it is returning undefined.