jquery replace newline with br Example – Convert new lines to br – nl2br function

jquery replace newline with br Example – Convert new lines to br – nl2br function

In this Post We Will Explain About is jquery replace newline with br Example – Convert new lines to br – nl2br function With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to jquery replace newline with brExample

In this post we will show you Best way to implement Convert new lines to br, hear for nl2br functionwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :  Laravel Global variable Sharing Data with all views

Replacing simple Line Breaks With
Tags Using JavaScript Example

    <textarea class="mylivedata"></textarea>  
      

    var temp_string_data = ;  

    function nl2br (mystr, is_xhtml) {     
        var simplebreaktag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';      
        return (mystr + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ simplebreaktag +'$2');  
    }  
    $(".mylivedata").val(nl2br(temp_string_data));  
      


javascript remove line breaks from string Examples

function nl2br (str, is_xhtml) {   
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';    
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}

Full Example of jQuery convert line breaks to br (nl2br equivalent)

jquery simple convert line breaks using nl2br nl br equivalent javascript examples



  
  <title>jQuery convert line breaks to br Examples</title>

  function dataconvert(){
   document.getElementById('mydata').innerHTML = myfunnl2br(document.getElementById('mycontent').value);
 }

 function myfunnl2br (str, is_xhtml) {   
  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';    
  return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}



<h1><a href="https://pakainfo.com/tutorials/">jQuery convert line breaks to br (nl2br equivalent)</a></h1>
     
  <div id="my_demo">
    <div id="mydata"></div>
    <form>
      <p><textarea id="mycontent">
        We are Web Technology Experts and Team who provide you very Important information on Web Development information,Examples and Demo, Interview Questions and Answers, live project problem solution and their solution and online free tutorials – “Pakainfo.com”.
		Open Browser or Safari.
		Open the simple Settings menu.
		Go to or Click the Advanced tab panel.
		Go to or Click the Change Settings push button.
		Go to or Click the LAN Local Area Network Settings button. ...
		Check "Use a proxy server for your LAN," menu choice and enter your set proxy  or here IP address set and  simple port number.
		Go to or Click OK button press.
	Go to or Click OK again button push in the change tab to Internet Options your window.
      </textarea></p>
      <p></p>
    </form>
  </div>


Example

Also Read :  How to Check check php version command line linux

I hope you have Got What is jQuery replace br line break with space And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

avatar
  Subscribe  
Notify of