开发者

jQuery appendTo listbox not working in IE

开发者 https://www.devze.com 2022-12-12 08:46 出处:网络
I have a listbox containing \"all\" the items and a second listbox that will contain \"selected\" items. I want to have it so that do开发者_Go百科uble-clicking an item in the \"all\" listbox adds that

I have a listbox containing "all" the items and a second listbox that will contain "selected" items. I want to have it so that do开发者_Go百科uble-clicking an item in the "all" listbox adds that item to the "included" listbox.

Currently i have :

$(document).ready(function()
{
    $('#AllAirlines option').dblclick(AddAirline);
}

function AddAirline() 
{
    $('#AllAirlines option:selected').remove().appendTo('#AirlineList');
}

Which works fine in FireFox... but in IE8 etc, fails. Any ideas why?


Here is a slightly updated version that also works in IE8 - it just doesn't like the event hook up... and you also forgot to close your document-ready...

$(document).ready(function()
{
    $('#AllAirlines').dblclick(function() { AddAirline(); });
});

function AddAirline() 
{
    $('#AllAirlines option:selected').remove().appendTo('#AirlineList');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消