How to write & ; (no space) without being converted into ‘&’;
Does backslash work ?
Like this
\&
Or try this
&
(But may need a semicolon at the end)
Dear hbar1st
No & didn’t work
That semicolon is the problem.
Can you paste your code so we can play with it?
function convertHTML(str) {
// :)
let myStr = str;
console.log(myStr.replace('&', '\&'));
if(str.indexOf('&')){
str.replace('&', '&')
console.log(str);
}
return str;
}
convertHTML("Dolce & Gabbana");
It is not complete yet.
Can u try %26
Instead?
%26 simply print ‘%26’
It did not convert into & ; (without space)
Is there anything like .escape() function with sanitize input?
maybe this one?
or this one
https://www.w3schools.com/jsref/jsref_encodeuri.asp
Not sure what is the difference on first look…
It convert string into url
it act like a string to url encoder
But has no effect on & ; (without space)
I think I’m misunderstanding something. You want & to appear as & ?
But I think you tried escaping right? Like this? \&
?