I have written the following code. But it is removing only not <br>
var docDesc = docDescription.replace(/( )*/g,"");
var docDesc1 = docDescription.replace(/(<br>)*/g,"");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can achieve removing
<br>with CSS alone:If that doesn’t fit your needs, and you want to really delete each
<br>, it depends, ifdocDescriptionis really a string (then one of the above solutions should work, notably Matt Blaine’s) or a DOM node. In the latter case, you have to loop through the br elements:Edit: Why Matt Baline’s suggestion? Because he also handles the case, where the
<br>appears in an XHTML context with closing slash. However, more complete would be this: