JSFiddle - React, Tailwind, and code Playground

HTML

<input type='text' id='searchbox' />

JavaScript

$("#searchbox").on('change', function() {
    var encodedValue = encodeURIComponent($("#searchbox").val());
    console.log('not encoded: '+JSON.stringify($("#searchbox").val()));
    console.log('encoded: '+JSON.stringify(encodedValue));
});