网易163免费邮箱中的“求职直通车”中的“求职意向”的JS代码主要是下面截图这块的代码!
能帮助解决者50分全给,我只有这么多了!我做了类似的,但是无法实现“重复添加的判断!”我做的页面:http://www.taody.com/1.html谢谢!

解决方案 »

  1.   

    添加到右边之前遍历作个判断$("#moveToRight").click(function(){ 
    var selectedText=$("#waitPerson option:selected")[0].text;
    var has=false;
    $("#alreadPerson option").each(function(i,o) {
    if(o.text==selectedText) {
    alert("此项已选择!");
    has=true;
    return;
    }
    });
    if(!has)
    $("#waitPerson option:selected").clone().appendTo("#alreadPerson"); 
                    //$("#waitPerson option:selected").remove(); 
                   // $("#waitPerson option:first,#alreadPerson option:first").attr("selected",true); 
                }); 
      

  2.   


    $("#alreadPerson option").each(function(i,o) {
                        if(o.text==selectedText) {
                            alert("此项已选择!");
                            has=true;
                            return;
                        }
      });这里执行好象有错误!
    我加了,没有任何反应,没错误提示,
    我是这样添加的            $("#waitPerson").dblclick(function(){ 
    //alert ($("#alreadPerson").children().length);
    if ($("#alreadPerson").children().length >4)
    {
    alert ("最多只能添加5项");
    return false;
    }

                    var selectedText=$("#waitPerson option:selected")[0].text;
                    var has=false;
                    $("#alreadPerson option").each(function(i,o) {
                        if(o.text==selectedText) {
                            alert("此项已选择!");
                            has=true;
                            return;
                       }
    $("#waitPerson option:selected").clone().appendTo("#alreadPerson"); 
                }); 
      

  3.   

    OK,多谢sohighthesky,根据你的代码,调试成功!谢谢!非常感谢!
      

  4.   

    你自己判断一下就行了,上面的代码我运行过了的,
    可以把上面的代码直接替换掉你的那个$("#moveToRight").click方法