Html 在附加的子项顶部添加颜色选择器

Html 在附加的子项顶部添加颜色选择器,html,Html,因此,我有一个脚本,将添加一个文本框,我想在该文本框的顶部添加一个色轮 如果这有帮助的话,我也在用电子。感谢您的帮助 函数createCommandField{ var input=document.createElement'option'; input.style.marginTop=1%; input.textContent=命令; input.name='Commands[]'; input.style.display='block' input.style.boxShadow='插入

因此,我有一个脚本,将添加一个文本框,我想在该文本框的顶部添加一个色轮 如果这有帮助的话,我也在用电子。感谢您的帮助

函数createCommandField{ var input=document.createElement'option'; input.style.marginTop=1%; input.textContent=命令; input.name='Commands[]'; input.style.display='block' input.style.boxShadow='插入0px 1px 0px 0px ffffff'; input.style.border='1px solid dcdc'; input.style.borderRadius='6px'; input.style.height=2%; input.style.padding='5px 30px'; input.style.fontFamily=Arial; input.style.fontWeight=粗体; input.style.fontSize=17px; 返回输入; } var select=document.getElementById'commandslist'; document.getElementById'addCommand'。addEventListener'click',函数e{ 选择.appendChildcreateCommandField; };
下面是一个jquery脚本,用于在“编辑:选定”选项双击时更改颜色输入

添加了一个函数,用于在同一选择的背景上应用选定的颜色,并取消选择以实现效果

祝你好运

函数createCommandField{ var input=document.createElement'option'; input.style.marginTop=1%; input.textContent=命令; input.name='Commands[]'; input.style.display='block' input.style.boxShadow='插入0px 1px 0px 0px ffffff'; input.style.border='1px solid dcdc'; input.style.borderRadius='6px'; input.style.height=2%; input.style.padding='5px 30px'; input.style.fontFamily=Arial; input.style.fontWeight=粗体; input.style.fontSize=17px; 返回输入; } $document.readyfunction{ var bgclr=; var parentopt=$'pckrbg'; $'commandslist'.changefunction{ var crntslct=$'commandslist'。子选项:选中'; crntslct.dblclick函数{ parentopt.click; parentopt.changefunction{ bgclr=parentopt.val; $'commandslist'。propselectedIndex,函数{ $this.children'选项:选中'.cssbackground,bgclr;//设置背景 $this.children'option:selected'.propselected,false;//取消选择选项; }; }; }; }; }; var select=document.getElementById'commandslist'; document.getElementById'addCommand'.addEventListener'click',函数E{ 选择.appendChildcreateCommandField; }; ->
您需要向附加的子项添加颜色选择器,还是需要在附加子项之前选择颜色?你还需要任何颜色选择器,比如按钮,从中获取颜色,或者你需要设计一个颜色选择器滚轮?我想在输入变量中添加一个类型为color的输入,你可以使用input.innerHTML+=;在返回输入行之前,但它需要一个JS来运行颜色选择器,只要它包含在选项列表中,所以它是无用的,不能使用。我想在按下按钮时创建颜色元素,然后将其位置设置为另一个元素的位置,并且颜色元素应该位于第二个元素的顶部。你能解释一下吗更多?所以运行我发布的代码,你可以看到它添加了一个文本框当它添加一个文本框时,我还想在该文本框中添加一个颜色选择器