我在创建一个文本框和一个可拖动的按钮。拖放到文本框
当我点击按钮时,某个文本被添加到文本框(JavaScript和HTML)的乞求中。
我想添加一个选项,将按钮拖入文本框,当我点击要添加到文本框中的按钮时,这会导致相同的文本。
如果可能,我也想选择在哪里添加此文字。也就是说,如果我拖动按钮并在文本框中的句子中间拖动,它会将文本添加到放置文本的句子中间,而不是放在文本框的开头。从提前
感谢。
编辑:
下面是代码我已经做的一部分,对不起它有点乱(为我做什么,我需要的一切把所有的字符串)。
var emoticon1 = "<input title='curious' onclick='add_tag("+'"curious"'+");' type='image' id='cur' src='/content/modules/dev/emoticons/curious.png' style='height:48px;width:48px;' />";
var emoticon2 = "<input title='confused' onclick='add_tag("+'"confused"'+");' type='image' id='con' src='/content/modules/dev/emoticons/confused.png' style='height:48px;width:48px;' />";
var emoticon3 = "<input title='helpful' onclick='add_tag("+'"helpful"'+");' type='image' id='help' src='/content/modules/dev/emoticons/helpful.png' style='height:48px;width:48px;' />";
var emoticon4 = "<input title='intersted' onclick='add_tag("+'"intersted"'+");' type='image' id='inte' src='/content/modules/dev/emoticons/interested.png' style='height:48px;width:48px;' />";
var tmp = "var txt=document.getElementById('commentTB').value;txt='#' + type + ' ' + txt ;document.getElementById('commentTB').value=txt;";
var fun = "<script> function add_tag(type) {"+tmp+"} </script>";
var emoticonsList = fun + emoticon1 + emoticon2 + emoticon3 + emoticon4;
此刻结果: how the current code looks
目前(我在Ubuntu的工作,如果它很重要),如果在Chrome运行它,它让我拖动按钮(图片),并把他们在文本中,但它把“src”放在文本框中,而不是我想要的文本。另一方面,在Firefox中,即使添加draggable =“true”,也不能拖动按钮。
你有什么迄今所做? – TechTreeDev
在编辑中添加了我迄今为止所做的。 – rfire