【发布时间】:2012-03-02 12:49:33
【问题描述】:
这是我的拖动开始:
dragstart: function(e) {
$(this).css('opacity', '0.5');
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('application/json', {
id: $(this).attr('id'),
header: $('header', this).text()
});
},
我想传递一些信息,例如 id 和 text。我的下降是:
drop: function(e) {
var data = e.dataTransfer.getData('application/json');
alert(data);
$(this).attr('id', data.id);
$('header', this).text(data.header);
},
但数据未定义,我无法访问我的数据。方法对吗?
谢谢!
【问题讨论】:
-
会不会和这个有关? stackoverflow.com/questions/7640234/…
标签: html drag-and-drop