我的selec2下拉列表未正确显示。
以下是代码:
//此处包含select2 CSS文件HTML代码:
<div>
<tr>
<td><b><bean:message key="label.student.display" />:</b>
<html:select property="stuCode" styleId="rollno" onchange="getStuData(this);">
<html:option value=""><bean:message key="label.student.select" /></html:option>
<html:option value="ABC">ABC</html:option>
<html:option value="XYZ">XYZ</html:option>
<html:optionsCollection name="studentForm" property="StuList" label="label" value="value" />
</html:select>
</td>
</tr>
</div>
//included javascript select2 tag
</body>
jQuery代码:
$(function() {
$("#rollno").select2();
});
包含Select2且在控制台中没有任何错误。但是输出不符合预期。
请注意:HTML页面中有多种表单。某些表单使用常规下拉列表而不是Select2。请帮助我解决此问题。谢谢!
在struts标记中给选择一个宽度,它应该可以工作。我以前也遇到过同样的问题。我认为这就是问题,我看不到其他任何错误。
您还可以使用select2的width参数并设置宽度。如果要在struts标记中提供百分比宽度,则在创建select2时请执行以下操作
$("#rollno").select2({
width: 'resolve'
});
同样显然,您也可以使用CSS在html中设置选择的宽度。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句