【发布时间】:2013-04-25 14:57:45
【问题描述】:
我目前正在使用 ajax 将新选项附加到多选框,但即使我尝试向它们添加标题属性,它们似乎根本没有显示。有什么我想念的吗?
这是在 Coffeescript 中完成的:
$.ajax(
type: 'get'
url: '/Filter/LookupClassification'
data: ( term: inputVal )
dataType: 'json'
success: (response)->
select = document.getElementById('getClassBox')
select.options.length = 0
$.each(response, (key, value)->
option = $(
'<option/>'
'title': value.toUpperCase()
'value': key
).text(key + ' - ' + value.toUpperCase())
$('#getClassBox').append(option)
)
$('#selectClassBox option').each((index, value)->
val1 = $(value).val()
if $('#getClassBox option').val() is val1
$('#getClassBox option[value=' + val1 + ']').remove()
)
)
【问题讨论】:
-
title属性从什么时候开始对options 有效,它怎么可能有用? -
@GrantThomas 我正在尝试将它用于鼠标悬停时的工具提示,如下所示:jsfiddle.net/spB3E
-
它会在 Chrome 26、IE 10 和 Firefox 20.0.1 的悬停上显示,除非我以某种方式看到其他人看不到的东西。
-
@GrantThomas - 至少从HTML 4开始。
-
@ÁlvaroG.Vicario 有趣的是 HTML5 规范没有提到“标题”。
标签: javascript jquery html