I have a JavaScript function that loops through each line. I want it to search for specific text on each line and hide the entire line if it contains that text. For example:
<input id="search" type="button" value="Run" />
<textarea id="main" style="height:150px;">
300 300 300
300 200 300
100 100 150
</textarea>
Javascript
$('#search').bind('click', function () {
var lines = $("#main").val().split("\n");
for (var i = 0; i < lines.length; i++) {
if($([i].contains('300' || '200'){
$(lines).css('display','none');
}
}
});
The code currently breaks the lines into 3 rows. However, how can I modify it to search for certain text within each row and hide those rows where the text is found, rather than just removing the number? So in the example above, the desired output would be:
100 100 150