I'm trying to count the number of lines in a string for each div. But I would also like to set a maximum number and if the string inside a div is equal/greater to that number to show a button.
Here's a codepen
jQuery:
$('.intro_text').each(function() {
var lines = $(this).find("div").val().split("\n");
var maxLine = 5;
if(lines > maxLine){
$(this).after("<button>toggle</button>");
}
});