I can't get the attr('title')
I have the following select:
- <select name="country_phone" id="country_phone">
<option value=""> </option>
<option title="+93" value="AF" >Afghanistan</option>
<option title="+355" value="AL" >Albania</option>
<option title="+213" value="DZ" >Algeria</option>
<option title="+1684" value="AS" >American Samoa</option>
<option title="+376" value="AD" >Andorra</option>
<option title="+244" value="AO" >Angola</option>
<option title="+1264" value="AI" >Anguilla</option>
<option title="+672" value="AQ" >Antarctica</option>
<option title="+1268" value="AG" >Antigua and Barbuda</option>
- </select>
If I now try to use:
- $('#country_phone').change(function() {
alert($(this).val());
$('#countryPhoneContainer').html($(this).attr('title'));
});
The 1st alert outputs the correct value of the selected item, but $(this).attr('title') is empty. It's also empty if I alert() it. Why ???
Thanks for help!