使用javascript和html的下拉列表

使用javascript和html的下拉列表,javascript,html,Javascript,Html,我已经创建了一个下拉列表,当我单击它应该从另一个字段中的下拉列表n中删除的值时。。 当我双击该字段中的值时,它应该返回到溺水列表 请给我一些想法一个简单的例子是: <script type="text/javascript"> function handleClick(e, listElement) { // Get the element that was clicked on var el = e.target || e.srcElement; // If th

我已经创建了一个下拉列表,当我单击它应该从另一个字段中的下拉列表n中删除的值时。。 当我双击该字段中的值时,它应该返回到溺水列表

请给我一些想法

一个简单的例子是:

<script type="text/javascript">

function handleClick(e, listElement) {

  // Get the element that was clicked on
  var el = e.target || e.srcElement;

  // If the element has class 'item' ...
  if (el && /item/.test(el.className)) {

    // Move it from its current list to the other one
    if (listElement.id == 'list-0') {
      document.getElementById('list-1').appendChild(el);

    } else {
      document.getElementById('list-0').appendChild(el);
    }
  }
}

</script>

<ul id="list-0" onclick="handleClick(event, this);">
  <li class="item">apple
  <li class="item">orange
  <li class="item">banana
</ul>

<ul id="list-1" onclick="handleClick(event, this);">
  <li>add stuff here...
</ul>

函数handleClick(e,liselement){
//获取单击的元素
var el=e.target | | e.src元素;
//如果元素具有类“item”。。。
if(el&&/item/.test(el.className)){
//将其从当前列表移动到另一个列表
如果(listElement.id='list-0'){
document.getElementById('list-1').appendChild(el);
}否则{
document.getElementById('list-0').appendChild(el);
}
}
}
    苹果 橙色 香蕉
  • 在这里添加内容。。。

当然,要使上述内容在网页中变得有用,需要做大量的工作。

问题是什么?请显示不起作用的代码。到目前为止您尝试了什么?尝试为此搜索和探索JQuery示例。我刚刚开始考虑是使用java脚本还是JQuery。。好的,谢谢,我会用jquery。