如何使标签的文本框[关闭](How to make tag text box [closed])

2019-08-02 18:02发布

在计算器我们可以看到一个文本框“标签”当我们做一个职位。

在键入一个单词和空格之成为一个标签。 成为一个标签后,我们续删除一个word.But我们可以通过单击X图像删除单词本身的信。

我想创建标签类似的文本框中。 在计算器有自动提示也与该文本框关联,但需要。我不认为。

任何帮助/链接可以理解的

Answer 1:

有这些网上一大堆。 我发现使用谷歌一些很容易。 看看这一个例子:

http://xoxco.com/projects/code/tagsinput/



Answer 2:

编辑:这是一个稍微不同的(更好)的功能类似的例子:
https://stackoverflow.com/a/14083331/383904


一个漂亮的小演示中,你可以轻松地升级和修改:

 $('#tags input').on('focusout',function(){ var txt = $.trim( this.value ); if(txt) { $(this).before('<span class="tag">'+txt+'</span>'); } this.value = ""; }); $('#tags').on('click','.tag',function(){ if( confirm("Really delete this tag?") ) $(this).remove(); }); 
 #tags{ float:left; border:1px solid #ccc; padding:5px; font-family:Arial; } #tags span.tag{ display:block; float:left; color:#fff; background:#689; padding:5px; padding-right:25px; margin:4px; } #tags span.tag:after{ position:absolute; content:"x"; border:1px solid; padding:0 4px; margin:3px 0 10px 5px; cursor:pointer; font-size:10px; } #tags input{ background:#eee; border:0; margin:4px; padding:7px; width:auto; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="tags"> <input type="text" value="" placeholder="Add a tag" /> </div> 



文章来源: How to make tag text box [closed]