william ganrot william ganrot - 3 months ago 55
jQuery Question

Javascript/Jquery Identify every row in a textdocument

What I need to be able to do is a to identify every row in a textfield or a text-file. So I can print any single row I want. For example push every row into an array (like this [row1][row2][row3]). I have no idea how to do this or if it's even possible. If it is i would appriciate some guidance, if it's not possible is there any other solution for my problem? Thank you!


Try to use the .split() function. A simple example might be like this:

 rows = $(".my-txt-area").val().split("\n");
 console.log("row 1: " + rows[0]);
 console.log("row 2: " + rows[1]);
 console.log("row 3: " + rows[2]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea class="my-txt-area" style="width: 100%; height: 200px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation...