Input simulates enter to generate tags

problem description

hundred house number, hit the keyboard to enter, will automatically generate a label. Now I want to generate the label automatically by simulating the carriage return, but the simulated carriage return has not achieved the effect of generating the label

.

the environmental background of the problems and what methods you have tried

cycle data, simulate enter

related codes

/ / Please paste the code text below (do not replace the code with pictures)
var arr = ["tag 1" "tag 2" tag 3"]

    var len = arr.length;
    $(".tags-container").keyup(function(event){
      if(event.keyCode ==13){
          console.log("")
      }
    });
    $(".remind").click(function(){
        $(".tags-container").addClass("focus");
        for(var n = 0;n<arr.length;nPP){

/ / console.log (arr [n]);

            var val = $(".tags-container input").val();
            console.log(val);
            $(".tags-container input").focus();
            $(".tags-container input").val(arr[n]);
            var e = jQuery.Event("keydown");//
               e.keyCode = 13;//keyCode=13
              $(".tags-container").trigger(e);//
        }
    })

clipboard.png

:
clipboard.png this is typed with the actual enter key

Jan.29,2022

<ul id="content"></ul>
    <div class="clearData"></div>
    <textarea onkeypress="func()" class="inputVal" oninput="inputFunc(this)"></textarea>
    <div onclick="sunmitFunc()"></div>

js:
var sendData= []; / / data to be sent

function func(event){ //
    event = event || window.event;
    if(event.keyCode==13){
        event.preventDefault();
        var val=$(".inputVal").val().replace(/(^\s*)|(\s*$)/g,"")
        if($(".inputVal").val()&&val!=""){
            $("-sharpcontent").append("<li class='selectVal'>"+$('.inputVal').val()+"<span class='deleteLabel'></span></li>");
            sendData.push($(".inputVal").val());
            $(".inputVal").val("");
        }
    }
}
$(".clearData").click(function(){ // 
    $("-sharpcontent").html("");
    $(".inputVal").val("");
    sendData=[];
})
$(document).on("click",".deleteLabel",function(){ // 
    $(this).parent().hide();
    sendData.splice($(this).parent().index(),1,"");
})
function sunmitFunc(){ //
    var newArr=[];
    for(var i=0;i<sendData.length;iPP){
        if(sendData[i]!=""){
            newArr.push(sendData[i]);
        }
    }
    console.log(newArr);//
} 

if you use the current framework, you don't have to DOM this way

Menu