JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<h3>The disappearing of a space at the end of a line</h3>
<input id="input" type="text" value="Space at the end " disabled="true">
<datalist id="datalist">
</datalist>
<input id="datalist-input" list="datalist">
<h6>(select the only option in the datalist and click somewhere to trigger the script)</h6>

JavaScript

let originalInput = $("#input").val();
$("#datalist").append(`<option>${originalInput}</option>`);
$("#datalist-input").change(function(){
var datalistText = $("#datalist-input").val();
if(datalistText !== originalInput){
	alert(`The original value: "${originalInput}" is not equal to: "${datalistText}"`);
}else{
  alert(`The original value: "${originalInput}" is equal to: "${datalistText}"`);
}}); // end change