Question about Managing JavaScript in Drupal 7 If you go to  https://www.drupal.org/node/756722#behaviors    at Behaviors section you will see:

  (function ($) {
     Drupal.behaviors.exampleModule = {
     attach: function (context, settings) {
     $('.example', context).click(function () {
     $(this).next('ul').toggle('show');
  });
 }


};

})(jQuery);

I think 'example' should be the name of a class like:

   &lt;p class="example"&gt;&lt;?php echo click here?&gt; &lt;?p&gt;


so when clicking on "Click here", the toggle will work. Am I right? And also what is 'ul' in $(this).next('ul').toggle('show');?

So if I have :

 for($b=1;$b&lt;$number;$b++)
   {  ?&gt;  
      &lt;p class="toggler" style="cursor:pointer;"&gt;&lt;?php echo "Commentsfor Paragraph $b:" ."&lt;br&gt;" . "&lt;br&gt;" ; ?&gt; &lt;/p&gt; 
     &lt;div class="comment"&gt; 
    &lt;?php
      print render($p[$b]); 
      ?&gt;
     &lt;/div&gt; &lt;?php  

      } 


and what I want to hide or show is the in , then can I write:

      &lt;script type="text/javascript"&gt;
       (function ($) {
         Drupal.behaviors.exampleModule = {
        attach: function (context, settings) {
         $('.toggler', context).click(function () {
          $(this).next('div').toggle('show');
        });
      }
     };


   })(jQuery);
 &lt;/script&gt;


or can I mention the class or id of div  in $(this).next('div').toggle('show'); , so that the data in that part will hide or show? I hope I am clear.
Those examples are not complete working code examples.

They are just to illustrate that in Drupal 6 you did this:

Drupal.behaviors.exampleModule = function (context) {
  // Your code goes here.
}


And in Drupal 7 you would generally do this:

Drupal.behaviors.exampleModule = {
  attach: function (context, settings) {
    // Your code goes here.
  }
};


The rest of the code in those examples is not relevant.

However:


Yes, it means that if you click an element with the class "example" it will run the code in your click handler. Your example code is buggy though, it should be like this: &lt;p class="example"&gt;&lt;?php echo 'click here'; ?&gt; &lt;/p&gt;
The "ul" is referring to an unordered list element. So it will get the next ul from the element you clicked and toggle it.


[EDIT]

To answer your additional question about the example code:


  or can I mention the class or id of div in $(this).next('div').toggle('show'); , so that the data in that part will hide or show?


Yes you can specify any selector you want, for example:

$('.comment').toggle('show');