2013-12-08 25 views
0

我想在可以進行多個搜索的情況下添加功能。我將爲此提供一個輸入字段,就像SO添加Tags一樣。我想複製相同的。如何在HTML中添加多個搜索字段

我該怎麼做?

+1

看看[選擇](http://ivaynberg.github.io/select2/)或[choosen]( http://harvesthq.github.io/chosen/)標記 –

+0

謝謝。這是我需要的。 – PythonEnthusiast

+0

是否有select2的CDN版本? – PythonEnthusiast

回答

1

您可以使用選擇2插件來做到這一點

<body> 
    <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.4/select2.css"> 
    <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> 
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.4/select2.js"></script> 
    <input type="text" id='selec2'> 
    <script type="text/javascript"> 
    jQuery(function($){ 
     $("#1").select2({ 
      tags: ["red", "green", "blue"], 
      maximumInputLength: 10, 
      tokenSeparators: [",", " "] 
     }); 
    }) 
    </script> 
</body> 

演示:Fiddle