I want to display the dropdown option value when I right-click on any option. At the moment when I right-click on the option, it simply selects the option and closes the dropdown instead of calling the getCountryName method and displaying it in the alert.
Could you please help me to achieve this?
HTML
<select id="ddlCountry">
<option val="Sweden" oncontextmenu="getCountryName(this); return false;">Sweden</option>
<option val="Denmark" oncontextmenu="getCountryName(this); return false;">Denmark</option>
<option val="Germany" oncontextmenu="getCountryName(this); return false;">Germany</option>
<option val="France" oncontextmenu="getCountryName(this); return false;">France</option>
</select>
Javascript
<script type="text/javascript">
function getCountryName(t) {
alert(t.value);
}
</script>