XUL:获取放置目标ID [英] XUL: Getting drop target ID

查看:107
本文介绍了XUL:获取放置目标ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码用于应该获取源项和目标项的ID的列表框项.它用于获取源并将其存储在data变量中.但是data2仅在目标列表项为空的情况下检索ID.如果目标中有文字,则无法使用.

The following code is used for listbox items supposed to get the ID of the source and target items. It works for getting the source and stores it in the data variable. But data2 only retrieves the ID if the target list item is empty. If the target has text it doesn't work.

如何获取列表项的ID,而不是列表项内的标签?

How can I get the id of the list item and not the tags inside the list item?

谢谢.

drop: function(event){

    var data = event.dataTransfer.getData("text/plain");
    var data2 = event.target.id;
    alert("DROPPED: "+data+" "+data2);
    event.preventDefault();
}

推荐答案

我个人将使用属性parentNode并继续使用层次结构,直到找到某种类型的列表项.

Personally, I would use the property parentNode and keep going up in the hierachy until I find something of type list item.

这篇关于XUL:获取放置目标ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆