I have so many DIV
which have <p>
and I want to set .each() for particular DIV's <p>
for that I have done below code.
var Selected_type = 'business'; //which comes dynamically
var para_id = Selected_type + '_ltr';
var text = "";
$(para_id + "p").each(function(index) {
if (index < count) {
text += '<p>' + ($(this).text()).trim() + "</p><br>";
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="col-xs-12" id="business_ltr" style="max-height: none; display: none;">
<p>Learn how to transform your life for the better with 16 of the Web’s favorite entrepreneurship and leadership articles from this year.</p>
<p>Mental fortitude is essential for entrepreneurship, and in this wildly popular Forbes article, </p>
</div>
<div class="col-xs-12" id="study_ltr" style="max-height: none; display: none;">
<p>With all the emphasis placed on education in our society it is remarkable to realize that there has never been an actual technology of study or a technology of education. </p>
<p>The first little gate that has to be opened to embark upon study is the willingness to know. .</p>
</div>
but this shows me undefined and doesn't show me any result.
but if I set $("p" ).each()
it is working but it is get all <p>
but I want particular DIV's
<p>
can anybody help me with this