This works fine in all browsers except IE can anyone explain why so I can fix it. I am displaying the index of a javascript object based on the index of the selected index of my dropdown list
$(document).ready(function () {
var pdata = [{ Name: "Apples", Price: 1.99 },{ Name: "Bananas", Price: 2.45 } ];
$('#produceTMPL').tmpl(pdata).appendTo('#produceList');
$(document).ready(function () {
$('#add1').click(function () {
var selected = $('#produceList option:selected').index();
item = pdata[selected];
console.log(selected);
$('#cart').append('<p>' + item.Name + ', ' + item.Price + '</p>');
});
});
HTML:
<div>
<select id="produceList">
<option>make a selection</option>
</select>