Skip to content

Instantly share code, notes, and snippets.

@mssyogi
Created February 2, 2018 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mssyogi/0a1065d889beb8662a98740e976add4a to your computer and use it in GitHub Desktop.
Save mssyogi/0a1065d889beb8662a98740e976add4a to your computer and use it in GitHub Desktop.
tags
<script type="text/javascript">
$(document).ready(function(){
$('#hello-world').keyup(function(){
var ov = $(this).val();
if(ov){
if(ov.indexOf(",")!==-1){
// console.log(ov);
var nv='';
var tags = ov.split(",");
var i=-1;
$.each(tags, function(key, data){
if(data.indexOf("#")==-1){
data = '#'+data;
}
if(i < 0) {
nv = $.trim(data);
i = 2;
} else {
nv = nv+','+data;
}
// i++;
console.log(key);
});
$(this).val(nv);
} else {
if(ov.indexOf("#")==-1){
$(this).val('#'+ov);
}
}
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment