I have a selection box for choosing a country code: -
<div class="selectWrap"> <select name="countryCode" id="countryCode"></select> </div>
It is populated using javascript and receives the following parameters: -
<option data-phone-code="+91">91 (India)</option>
Now I want to select only the value +91.
I tried to do it
var country = document.getElementById("countryCode"); var prefix = country.options[country.selectedIndex].value;
But this returns a Full value with the country.
How can i achieve this?
source share