这可能吗?我从不同的来源填写我的下拉列表。我正在考虑分离不同的条目 odf 添加一个像这样的自定义属性:
<option value="12" customatrribute: "123" >NAME</option>
最佳答案
你正在使用的属性被认为是无效的,如果你想自己做,你需要有data-
前缀,因为它符合 HTML5 规范。
来自规范:
A custom
data
attribute is an attribute in no namespace whose name starts with the string "data-
", has at least one character after the hyphen, isXML-compatible
, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).
所以你可以使用类似的东西
<option value="12" data-customatrribute="123" >NAME</option>
另请注意,您需要使用 =
而不是 :
正如您评论的那样,这是源代码的屏幕截图,它确实为我显示了
关于html-select - 我可以在选择(下拉)中将自定义属性添加到选项值吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18957094/