<select> only shows first char of selected option

前端 未结 7 945
予麋鹿
予麋鹿 2020-12-01 02:08

I have a standard select box which I\'m populating using jquery by appending options, but for some reason IE9 only shows the first character of the selected option. Needless

7条回答
  •  無奈伤痛
    2020-12-01 02:22

    I've just fixed the same issue by changing how the select element was being initialised (dynamically created within a jQuery widget).

    Example A

    This doesn't work:

    var select = $('').attr('size', 7) // Yay
    

    Example B

    Similarly, the following doesn't work:

    self.element.append('').attr('name', 'mySelect');
    self.element.append(mySelect);
    

    Conclusion

    I'd love to be able to explain the above but I'm afraid I can't. Regardless, this might save folk from adding a bunch of CSS hacks to their code unnecessarily.

提交回复
热议问题