以前总想到网上找一个这样的,但是一直没有找到,所以我自己写了一个。希望能帮助到看到的童鞋。
如果谁有更强大的插件,跟我留一个地址,非常感谢!
效果如下:
代码如下:
$(\"#\"+$this.attr(\"id\")+\"btnReSelectAll\").click(
function(){
$(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\").each(function(i){
$(\"<option name=\'\"+$this.attr(\"id\")+\"opSelect\' id=\'\"+this.id+\"\' value=\'\"+this.value+\"\'>\"+$(this).text()+\"</option>\").appendTo(\"#\"+$this.attr(\"id\")+\"seSelect\");
});
$(\"#\"+$this.attr(\"id\")+\"seReSelect\").empty();
opts.onChange($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\"));
}
);
$(\"#\"+$this.attr(\"id\")+\"btnSelectOne\").click(
function(){
if($(\"#\"+$this.attr(\"id\")+\"seSelect\").val()){
var arrChecked= $(\"#\"+$this.attr(\"id\")+\"seSelect option:checked\")
for(var i=0;i<arrChecked.length;i++){
$(\"<option name=\'\"+$this.attr(\"id\")+\"opReSelect\' id=\'\"+arrChecked[i].id+\"\' value=\'\"+arrChecked[i].value+\"\'>\"+$(arrChecked[i]).text()+\"</option>\").appendTo(\"#\"+$this.attr(\"id\")+\"seReSelect\");
$(\"option[name=\'\"+$this.attr(\"id\")+\"opSelect\']\").each(function(j){
if(this.value==arrChecked[i].value){
$(this).remove();
}
});
}
opts.onChange($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\"));
}
else
{
$.dashboard.alert(\"Tip\",\"Please select a report!\")
}
}
);
$(\"#\"+$this.attr(\"id\")+\"btnReSelectOne\").click(
function(){
if($(\"#\"+$this.attr(\"id\")+\"seReSelect\").val()){
var arrChecked= $(\"#\"+$this.attr(\"id\")+\"seReSelect option:checked\");
for(var i=0;i<arrChecked.length;i++){
$(\"<option name=\'\"+$this.attr(\"id\")+\"opSelect\' id=\'\"+arrChecked[i].id+\"\' value=\'\"+arrChecked[i].value+\"\'>\"+$(arrChecked[i]).text()+\"</option>\").appendTo(\"#\"+$this.attr(\"id\")+\"seSelect\");
$(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\").each(function(j){
if(this.value==arrChecked[i].value){
$(this).remove();
}
});
}
opts.onChange($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\"));
}
else
{
$.dashboard.alert(\"Tip\",\"Please select a report!\")
}
}
);
$(\"#\"+$this.attr(\"id\")+\"btnUp\").click(
function(){
if($(\"#\"+$this.attr(\"id\")+\"seReSelect\").val()&&$(\"#\"+$this.attr(\"id\")+\"seReSelect option:checked\").length==1){
var index=$(\"#\"+$this.attr(\"id\")+\"seReSelect\")[0].selectedIndex;
$($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\")[index]).after($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\")[index-1]);
opts.onChange($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\"));
}
else
{
$.dashboard.alert(\"Tip\",\"Please select a report!\")
}
}
);
$(\"#\"+$this.attr(\"id\")+\"btnDown\").click(
function(){
if($(\"#\"+$this.attr(\"id\")+\"seReSelect\").val()&&$(\"#\"+$this.attr(\"id\")+\"seReSelect option:checked\").length==1){
var index=$(\"#\"+$this.attr(\"id\")+\"seReSelect\")[0].selectedIndex;
$($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\")[index]).before($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\")[index+1]);
opts.onChange($(\"option[name=\'\"+$this.attr(\"id\")+\"opReSelect\']\"));
}
else
{
$.dashboard.alert(\"Tip\",\"Please select a report!\")
}
}
);
});
};
})(jQuery);
本文地址:https://www.stayed.cn/item/6410
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我