Created
February 2, 2018 10:03
-
-
Save mssyogi/0a1065d889beb8662a98740e976add4a to your computer and use it in GitHub Desktop.
tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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