I have one input
<input type="text" style="width:200px" id="myInputTags" placeholder="add tag" />
<input type="button" id="btnId" />
in script
jQuery("#myInputTags").textext({ plugins: 'tags' });
now when I press enter in this input the tag is created, but I want to added this tags after click on my button and after keypress "space" some proposal?
Hi.
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]);
}
See a Live Demo of this
Docs: TexExt - Adding Tags Directly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With