Monday 1 December 2008

JQuery - Count Paragraphs

Add following click handlers to page using console in FireBug
  • $('#NoOfParagraphs').click(showNoOfParagraphs)

Example taken from here docs.jquery.com

..1..

"The quick brown fox jumps over the lazy dog" is a pangram (a phrase that contains all of the letters of the alphabet). It has been used to test typewriters and computer keyboards, and in other applications involving all of the letters in the English alphabet, because it is also a short coherent sentence.

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 has survived not only five centuries, but also the leap into....

..4..



function showNoOfParagraphs(e) 
{
  $('#NoOfParagraphs').click(function() {
  $("div.FadeAndAnimation p.ParagraphResults").append("   Paragraph Count :-" +
$("div.FadeAndAnimation p").size() + "
"); }

No comments: