0

Hi Guys I am New to javascript. I am writing inline javascript code that contains alert Function. when i try to add break line tag it doesnt work. Instead of going to the next line the br tags is written as if it was a text. Why is this happening and how can i fix this i.e. how can I make multiple line alert message.

Here is My Code

<input type="button" value="Click Here" onclick="alert('First Line <br/> Second Line')">

Any Help will be appreciated.

1 Answer 1

3

<br /> is html tag and browser decides how to render it in html page. Alert function only displays string and does not render html content. \n represents line break in string:

alert('First Line\n Second Line');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.