Vasanthakumar m

Vasanthakumar m

  • 1.8k
  • 75
  • 1.1k

Javascript Issue (For Loop)

Jul 5 2020 6:28 AM
Hi Techiee,
I have 100 number of paragraph binding from database to Html code using List in mvc. But Inside each Paragraph i need to give one Br tag. Where the one sentence finished.
Here i attached my code and javascript.
But My code will give the Br tag for First paragraph.Rest of 99 paragraph Br tag is not taking it, Any Solution for it.
What is Lorem Ipsum Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard. Dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book it
  1. <html>  
  2. <head>  
  3. </head>  
  4. <body onload="myFunction()">  
  5. @foreach (ImgViewModel ourteamdesc in Model.OurTeamDesc)  
  6. {  
  7. <div id="demo" >  
  8. <p>@tbl.Designation</p>  
  9. </div>  
  10. }  
  11. <script>  
  12. function myFunction() {  
  13. var str = document.getElementById("demo").innerHTML;  
  14. var res = str.split(".").join("<br />");  
  15. document.getElementById("demo").innerHTML = res;  
  16. }  
  17. </script>  
  18. </body>  
  19. </html>  

Brought to you by:

Answers (3)