Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Select2下拉列表未在带有struts标记的UI中正确显示_Javascript_Jquery_Dropdown_Jquery Select2 - Fatal编程技术网

Javascript Select2下拉列表未在带有struts标记的UI中正确显示

Javascript Select2下拉列表未在带有struts标记的UI中正确显示,javascript,jquery,dropdown,jquery-select2,Javascript,Jquery,Dropdown,Jquery Select2,我的selec2下拉列表未正确显示 代码如下: //这里包括select2 CSS文件 HTML代码: <div> <tr> <td><b><bean:message key="label.student.display" />:</b>

我的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>
控制台中包含Select2,但没有任何错误。但输出不符合预期


请注意:HTML页面中有多个表单。某些表单使用普通下拉列表而不是选择2。请帮我解决这个问题。提前谢谢

在struts标记中为select指定一个宽度,它应该可以工作。我以前也遇到过同样的问题。我想这就是问题所在,我看不出还有什么不对的地方

您还可以使用select2的宽度参数并设置宽度。如果您想在struts标签中指定百分比宽度,则在创建时选择下面的2 do

$("#rollno").select2({
    width: 'resolve'
});
显然,您还可以使用css在html中设置select的宽度

$("#rollno").select2({
    width: 'resolve'
});