duanao4503 2015-10-25 13:39
浏览 394
已采纳

将代码嵌套在input元素中

I am looking for someone to guide me in the right direction.

I have an input form. I want to make it so when a user types in something such as 'landscaping', it checks a file(json), and if 'landscaping' is found, then it creates a small box inside the input form. Allowing users to stack multiple inline boxes. It would be something similar to this:

enter image description here

As I was posting the question, I realized that this website uses the exact function I'm looking for, so the best example is I'm looking to make something like the tag input form at the bottom of the post question page.

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • duanli4146 2015-10-25 13:43
    关注

    Select2 does that. You can view it's multiple select boxes example here.

    $(".js-example-basic-multiple").select2();
    
    <select class="js-example-basic-multiple" multiple="multiple">
      <option value="landscaping">Landscaping</option>
      ...
      etc. all options you need
    </select>
    

    so you can add all your data in the json file as options to the select box. Or if you see more of the examples, it can load the options from an array (Loading array data) or even from a remote file that returns JSON (Loading remote data).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!