Question about Managing JavaScript in Drupal 7
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');