简体   繁体   中英

Select2 Always show placeholder

I am using a select2 component for selection.

I fiddled an example together here: https://fiddle.jshell.net/mmo2dqno/15/

What I am trying to do is:

  • Select an item via the select2 widget
  • Show that item in the div below
  • Dont show the label in the search box.

This works fine. The problem is, that when one item is selected, the searchbox isn't showing the placeholder attribute anymore.

How can I tell the browser to assume the input as empty and show the placeholder again?

You could kill the select2 plugin with JS, and then load it again. Or you could use Js to choose an disabled placeholder option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM