I am trying to use while creating a string with the new line.
Here is what I tried.
tooltip = "User is already present."+ + props.email;
But this is not working .while showing the tooltip.
Can any one help me with this ?
For example, you want to have the following text:
Hi!
I like JS
You can use \n:
const myMessage = 'Hi!\nI like JS;'
Or template strings:
const myMessage = `Hi!
I like JS`;
Use template literals in javascript it makes it more easier in all cases you do not need to add additional "\n" each time to add new line just right a paragraph with in quotes for help see this link it describe it very clearly
you need to set the html and get the html, like in below code you can remove first and last line and can use it as it is.
var props={email:'[email protected]'}
var htmlObject = document.createElement('div');
htmlObject.innerHTML = "User is already present. " + props.email;
tooltip = htmlObject.innerHTML ;
alert(tooltip);
You must use
\n
in JavaScript code and
white-space: pre-line;
in CSS to display new line
white-space. The full rule would be be white-space: pre-line.white-space: pre-line. I don't know how to edit my post.
User is already present