Reputation: 424
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.
Upvotes: 0
Views: 913
Reputation: 51861
<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');
Upvotes: 3