Ajax动态加载后下拉框默认选中问题

$.each(data.result,function(i,emp){
                    s='<tr onMouseOut="out(this)" onMouseOver=over(this)>'+
                        '<td>'+emp.employeeName+'</td>'+
                        '<td>'+emp.employTime+'</td>'+
                        '<td>'+emp.organization.organizationName+'</td>'+
                        '<td>'+emp.position+'</td>'+
                        '<td><select id="mySelect">'+
                        '<option value=3>通过</option>'+
                        '<option value=4>入职</option></select></td>'+
                        '<td>'+
                            '<div class="hidden-sm hidden-xs action-buttons">'+
                               ' <a class="blue" onclick=browse(\"'+emp.employeeId+'\")>'+
                                   ' <i class="ace-icon fa fa-search-plus bigger-130"></i>'+
                                '</a>'+

                                ' <a class="green" onclick=update(\"'+emp.employeeId+'\")>'+
                                    '<i class="ace-icon fa fa-pencil bigger-130"></i>'+
                               ' </a>'+

                               ' <a class="red" onclick=del(\"'+emp.employeeId+'\")>'+
                                   ' <i class="ace-icon fa fa-trash-o bigger-130"></i>'+
                               ' </a>'+
                           ' </div>'+
                       ' </td>'+
                    '</tr>';
                    $("#tb").append(s);
                    $("tr:last").find("#mySelect option[value='"+emp.employeeState+"']").attr("selected",true);

                });

  $("tr:last").find("#mySelect option[value='"+emp.employeeState+"']").attr("selected",true); 

每次得到表格的最后一行的下拉框$("tr:last").find("#mySelect option[value='"+emp.employeeState+"']"),比对值相等就选中

展开阅读全文

没有更多推荐了,返回首页