I am trying to make a autocomplete system using jquery but i get the following error from firefox developer console.
content.match is not a function
What i am missing here anyone can help me please ?
Here is my Jquery code:
$(document).ready(function(){
var timer = null;
var tagstart = /@/gi;
var tagword = /@(\w+)/gi;
$("body").delegate(".addpost", "keyup", function() {
clearTimeout(timer);
timer = setTimeout(function() {
var contents = $(this).text();
var goWord = content.match(tagstart);
var goname = content.match(tagword);
var ID = $(this).attr("id");
if (goWord.length > 0) {
var appendAfterHere = $(".tag_"+ID).after('<div class="mentions"></div>');
if (goname.length > 0) {
}
}
}, 500);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="postit tag_1">
<textarea name="" id="1" cols="30" rows="10" class="addpost" placeholder="Start to type with @mention"></textarea>
</div>
</div>
HERE is a codepen demo page also.