大家好,我已经构建的拖放应用程序在chrome和firefox中完美运行,但是当我在IE上尝试它时,我得到“需要对象”作为错误。所以draggable()根本不起作用。有人可以帮我解决这个问题吗?
function readJSON(json, i, end) {
myarray = eval(json);
$.each(myarray, function (index, value) {
if (i <= end && i == index) {
var $str = value.split('<br/>');
var $tooltip = $('<span></span>').html($str[0]).addClass('tooltiphidden');
var $newDiv = $('<div id =\"' + $str[3] + '\"></div>').addClass('items').html($str[1] + ' ' + $str[2]);
$newDiv.append($tooltip);
$newDiv.mousedown(function () {
$newDiv.contents("span:last-child").css({
display: "none"
});
moveditem = $str[0] + '<br/>' + $str[2];
}).draggable({
helper: 'clone',
opacity: 0.5
});
$('div.selectedItemlist').droppable({
accept: 'div.items',
drop: function (e, ui) {
$newSelectedItem = $('<div id=\"' + ui.draggable.attr('id') + '\"></div>').html(ui.draggable.html()).addClass('dropitems');
$tooltip = $('<span></span>').html(moveditem).addClass('tooltiphidden');
$('input#inrs').val($('#inrs').val() + ui.draggable.attr('id') + ',');
$('div.selectedItemlist').append($newSelectedItem);
ui.draggable.remove();
$('div.selectedItemlist').css({
backgroundColor: 'white',
opacity: 1
});
},
over: function (e, ui) {
$('div.selectedItemlist').css({
backgroundColor: 'red',
opacity: 0.2
});
},
out: function (e, ui) {
$('div.selectedItemlist').css({
backgroundColor: 'white',
opacity: 1
});
}
});
$newDiv.appendTo('div.suggestions');
i++;
}
});
}