Ale*_*lex 5 jquery jquery-plugins
我有一个输入
<input type="text" style="width:200px" id="myInputTags" placeholder="add tag" />
<input type="button" id="btnId" />
Run Code Online (Sandbox Code Playgroud)
在脚本中
jQuery("#myInputTags").textext({ plugins: 'tags' });
Run Code Online (Sandbox Code Playgroud)
现在,当我在此输入中按Enter键时,标签已创建,但我想在点击我的按钮后添加此标签,并在按下"空格"后提出一些建议?
你好.
jQuery("#myInputTags")
.textext({
plugins: 'tags, prompt',
prompt: 'add tag'
})
.keypress(function(event){
//'Space' key is pressed in keyboard
if(event.which==32){
addTag();
}
});
jQuery("#btnId").click(function(){
addTag();
})
function addTag(){
//Take the value from text input
var tag = $('#myInputTags').val();
//Clear the text input and add tag
$('#myInputTags').val('').textext()[0]
.tags().addTags([tag]);
}
Run Code Online (Sandbox Code Playgroud)
文档: TexExt - 直接添加标签
| 归档时间: |
|
| 查看次数: |
970 次 |
| 最近记录: |