ホームページ  >  記事  >  ウェブフロントエンド  >  JQUERY_jquery に基づいた 2 つの ListBox サブ項目の相互調整の実装コード

JQUERY_jquery に基づいた 2 つの ListBox サブ項目の相互調整の実装コード

WBOY
WBOYオリジナル
2016-05-16 18:06:551356ブラウズ

HTML:

复制代 代码如下:















未选择颜色


已选择颜色










对应JS メソッド:
复制代 代码如下:

関数 listMove(main, follow, Hidetextbox, isBack, Index) {
if (index return;
var o = 未定義;
変数ソース;
var は個別です。
var dddd;
if (!isBack) {
//IE6 に存在する BUG に getElementById を使用します
source = $('#' main);// window.document.getElementById(main);
distinct = $('#' が続きます); //window.document.getElementById(follow);
}
else {
source = $('#' follow); // window.document.getElementById(follow);
distinct = $('#' main); // window.document.getElementById(main);
}
var hid = $('#' Hidetextbox)[0]; // document.getElementById(hidetextbox);
if (インデックス != 未定義) {
var op = "オプション:eq(" インデックス ")";
source.find(op).each(function () {
distinct.append("");
$(this).remove()
});
}
else {
source.find("option:selected").each(function () {
$(this).remove();
distinct.append("< ;option value='" $(this).val() "'>" $(this).text() "");
});
}
var str = "";
//遍历Listbox,取得选中项的值
$('#' main ' option').each(function () {
str = $(this).val() ',';
});
hid.value = str;
}
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。