0
我使用一些代碼從 http://abeautifulsite.net/blog/2008/04/jquery-multiselect/#demomultiSelect - 下拉菜單。當新選項添加
它看起來巨星,但我需要清除dropdwn並添加新的選項寬度改變。當我這樣做時,寬度不變,並且展開。
我該如何添加選項寬度改變multidropdown的佈局?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script src="http://labs.abeautifulsite.net/projects/js/jquery/multiSelect/jquery.bgiframe.min.js" type="text/javascript"></script>
<script src="http://labs.abeautifulsite.net/projects/js/jquery/multiSelect/jquery.multiSelect.js" type="text/javascript"></script>
<link href="http://labs.abeautifulsite.net/projects/js/jquery/multiSelect/jquery.multiSelect.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
// Options displayed in comma-separated list
$("#d").multiSelect({ oneOrMoreSelected: '*' });
$("#f").multiSelect({ oneOrMoreSelected: '*' });
});
var i=0;
function insOptions() {
var ddl = $("#d");
ddl.append("<option value='" + i+ "'>" + i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i + "</option>");
i++;
ddl.append("<option value='" + i+ "'>" + i + "</option>");
i++;
ddl.append("<option value='" + i+ "'>" + i + "</option>");
++i;
//document.getElementById("control_9").options.add(opt);
var widthh = $("#d").width();
$("#d").multiSelect({ oneOrMoreSelected: '*' });
var ddl = $("#f");
ddl.append("<option value='" + i+ "'>" + i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i+i + "</option>");
i++;
ddl.append("<option value='" + i+ "'>" + i + "</option>");
i++;
ddl.append("<option value='" + i+ "'>" + i + "</option>");
++i;
//document.getElementById("control_9").options.add(opt);
var widthh = $("#f").width();
$("#f").multiSelect({ oneOrMoreSelected: '*' });
}
</script>
</head>
<body>
<form action="" name="myForm" method="post">
<p>
<select id="d" multiple="multiple" style="width: 120px">
<option value=""></option>
<option value="option_1">Option 1</option>
<option value="option_2">Option 2</option>
</select>
</p>
<p>
<select id="f" multiple="multiple" style="width: 220px">
<option value=""></option>
<option value="option_1">Option 1</option>
<option value="option_2">Option 2</option>
</select>
</p>
<p>
<input type="button" value="Add new options in dropdown" onclick="insOptions();">
</p>
</form>
</body>
</html>