日期:2014-05-16  浏览次数:20304 次

JS转换为jquery
var i = 0, j = 0;
    for (i=0; i<form1.select1.options.length; i++) {
      if( form1.select1.options(i).selected == true){
        var add_ok = true;
        for (j=0; j<form1.select2.options.length; j++) {
          if (form1.select2.options(j).value == form1.select1.options(i).value){
            alert(form1.select2.options(j).text +" 已经存在!" );
            add_ok = false;
            break;
          };
        };
        if (add_ok){
            var oOption = document.createElement("OPTION");
            oOption.text=form1.select1.options(i).text;
            oOption.value=form1.select1.options(i).value;
            form1.select2.add(oOption);
           form1.select1.remove(i);
          i=i-1;
        };
      };
    };

求大神帮帮忙转换成jquery,谢谢啦
JavaScript jQuery

------解决方案--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>