<div class="layui-form-item">
<label class="layui-form-label" style="width: auto"><span class="x-red">*</span>部门名称</label>
<div class="layui-input-inline" style="width: 50%; float: right; margin-right: 20%">
<select id="departmentId" name="departmentId" lay-filter="departmentId" th:field="${workgroup.departmentId}">
<option th:each="d:${departmentSelect}" th:value="${d.id}" th:text="${d.departmentName}"></option>
</select>
</div>
</div>
<div class="layui-form-item layui-hide">
<label class="layui-form-label" style="width: auto"><span
class="c-red">*</span>部门名称:</label>
<div class="layui-input-inline " style="width: 50%; float: right; margin-right: 20%">
<input type="text" class="layui-input"
name="departmentName" placeholder="部门名称"
id="departmentName" />
</div>
</div>
上边是个下拉框,下面隐藏的输入框去获取下拉框的文本
$("#departmentName").val($("#departmentId").find("option:selected").text());