How to add Title attribute to dynamically filled <SELECT>

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);
        }
    }
}

      

How can I give each of them a <option>

hint?

+3


source to share


1 answer


From this question , maybe you just need to add an attribute title

. In this case, this should work:



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;
        }
    }
}

      

+3


source







All Articles