Search code examples
javascriptdom-eventshideshow

Understanding a Javascript Function


I don't really know anything about Javascript and I am trying to understand this piece of code:

<a href="javascript:void(0);" onClick='toggle_detail(this, "value-computations", "3")' ">

The part I don't understand relates to the portion that indicates onClick='toggle_detail.. Is this a custom function or a native Javascript function?

Ultimately I am looking to re-write this anchor tag so that on click it displays <div class="details"> and on the second click it hides the content of <div class="details">.

All help is greatly appreciated, as I know nothing about Javascript.


Solution

  • toggle_detail is a custom function. It should be defined somewhere else on the page, or in a script that the page links to. Here's a good reference/tutorial on javascript.