我正在使用webkit拖放功能,但是在拖动时我试图检索要删除的特定div的索引
var data = new Array ("a","b","c","d","e","f","g");
var data1 = new Array ("c","b","e","d","a","f","g");
var check ="" ;
var test = "";
var test1 = 0;
var str = "abcdefg";
$(document).ready(function(){
alert("hello");
$('.content').each(function(){
var text1 = $(this).text();
var element = this;
var draggab = new webkit_draggable($(this).attr('id'),{
onStart : function(){
var text1 = $(element).text()
console.log("start"+text1);},
var dropable = webkit_drop.add($(this).attr('id'),{
accept : ['content'],
onDrop:function(){
var thise = $(this);
console.log($(thise).index(this));
console.log("Drop");
alert($('.content').index() )
alert(text1)
alert(data[$('.content').index(this)] == text1);
if(data[$('.content').index(this)] == text1)
{
var condrop=$(this).html()
alert(condrop);
$(element).html(condrop);
$(this).html(text1);
}
},
这里的内容是div ID,我想要该特定div的索引。
最佳答案
它应该像这样简单:
onDrop:function(){
var $this = $(this);
console.log("Drop");
console.log($this.index());
);
关于jquery - 检索放置元素的索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11027415/