共计 782 个字符,预计需要花费 2 分钟才能阅读完成。
定义和用法
属性说明
autofocus
autofocus 规定下拉列表应在页面加载时自动获得焦点。
disabled
disabled 规定应禁用下拉列表。
form
表单 id 定义下拉列表所属的表单。
multiple
multiple 规定可以一次选择多个选项。
name
名称 定义下拉列表的名称。
required
required 规定在提交表单之前用户必须选择一个值。
size
数字 定义下拉列表中可见选项的数量。
2、jquery 中 select 的 text 和 value 的用法
$(“#select”).val(“***”); // 设置 value 为 *** 的项选中
$(“#select”).change(function(){}); // 当选择内容改变时触发
$(“#select”).find(“option:selected”).text(); // 获取 select 选择的 text 值
$(“#select”).val(); // 获取 select 选择的 value 值
3、select 的 Thymeleaf 中 th:field 用法
th:field,用法:th:field=”*{name}”
th:field,默认可以基于值,选中默认值。需要注意的是,th:field 需要搭配 th:object 使用。
原文地址: 【HTML】select 标签,select 的 jquery 用法,select 的 Thymeleaf 中 th:field 用法