【问题标题】:How can I add a Title attribute to a dynamically populated <SELECT>如何将 Title 属性添加到动态填充的 <SELECT>
【发布时间】:2013-02-06 10:47:23
【问题描述】:
function dynAddOption(list, elementToBeAdded){
    if( list.length > 0) {
        for(var index = 0;  index < list.length; index ++){
            elementToBeAdded.options[index + 1]  = new Option(list[index].description, list[index].id);
        }
    }
}

如何为每个&lt;option&gt;s 提供工具提示?

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

this question看来是可以的,只需要添加一个title属性即可。在这种情况下,这应该有效:

function dynAddOption(list, elementToBeAdded){
    if (list.length > 0) {
        for(var index = 0; index < list.length; index ++) {
            var opt = new Option(list[index].description, list[index].id);
            opt.title = 'Foo'; // < this is the tooltip
            elementToBeAdded.options[index + 1] = opt;
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-21
    • 2019-05-16
    • 2011-01-15
    • 1970-01-01
    • 2014-05-03
    • 2020-11-05
    相关资源
    最近更新 更多