jquery :Find the new line character and replace it with <br>

In my page one of the table column has the html like below

My world Logistics,\n Hamburg Industriestrasse \n 21107 Megas Sorter HH India

wherever there is \n i need to replace it withe html tag <br>

How can do it in Jquery, javascript?

Answers


<script>
var messagetoSend = document.getElementById('x').value.replace(/\n/g, "<br />");
alert(messagetoSend);
</script>

X is the table name.


Need Your Help

java.lang.NullPointerException: the servlet is never executed?

java jsp maven tomcat servlets

I'm learning how to do a maven dynamic web application with Eclipse and Tomcat. The applicacion works without servlet, but I get that error when I try to introduce it in my code. I debugged to find...

How to add a the share 'menu' like this?

iphone facebook twitter social

Does any of you guys know what this 'menu/view' is called and how to implement this?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.