encodeURI ()
The method does not encode ASCII letters and numbers, nor does it encode these ASCII punctuation marks:-_. ! ~ * ' ().
The purpose of this method is to fully encode the URI, so the encodeURI () function is not escaped for the following ASCII punctuation mark with a special meaning in the URI:;/?:@&=+$,#
encodeURIComponent ()
The method does not encode ASCII letters and numbers, nor does it encode these ASCII punctuation marks:-_. ! ~ * ' ().
Other characters (such as:;/?:@&=+$,# These punctuation marks used to separate the URI component) are replaced by one or more hexadecimal escape sequences.
Tip: Note the difference between the encodeURIComponent () function and the encodeURI () function,
The former assumes that its parameters are part of a URI (such as a protocol, host name, path, or query string). Therefore, the encodeURIComponent () function escapes punctuation marks that are used to separate the various portions of the URI.
The above content is from W3school
When submitting HTML element tags, use encodeuricomponent () to encode HTML element content in case the HTML tag is not properly transcoded after submission
JavaScript URL Encoding Issues