my code :
<select class='country'>
<option value='usa'><span class='nameCountry'>America</span> <span class='idCountry'>1</span></option>
<option value='sgd'><span class='nameCountry'>Singapura</span> <span class='idCountry'>2</span></option>
<option value='thi'><span class='nameCountry'>Thailand</span> <span class='idCountry'>3</span></option>
</select>
<div class="result">
<input type="text" name="kodeCountry" />
<input type="text" name="idCountry" />
<input type="text" name="nameCountry" />
</div>
here's my jquery code :
$(".country").change(function(){
var kode = $(this).val();
var name = $(".country option .nameCountry").html();
var id = $(".country option .idCountry").html();
console.log(kode);
console.log(name);
console.log(id);
});
result in console :
name and id = undefined
so, how to display the variable name and variable id? Thx..