开发者

How to create dropdown list with "new value" option?

I would like to create a dropdown list wher开发者_Python百科e the last option will be to enter a new value. How could I create this ?

Is there any jQuery plugin that provides such thing ?


There is no Html element that can do what you are looking for natively.

However as a workaround, you can bind a change event handler to your dropdown list. The rest depends on how exactly you would like the user to enter the new value:

$("#theList").change(function (e) {
                    //open a thickbox asking for the value, convert the dropdown list to a regular input or whatever...
                });

Note that some browsers raise an onchange event when the listbox is changed, others only when it's change and loses focus. So you might also want to listen to mousedown and keydown events if you want your UI to provide a consistent behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜