I am trying to perform some actions when clicking a link in my application.
For example, I am creating a guide containing several internal links within a document. Currently, I will handle them like this:
function waitForClick() { $('#about').click(function() { $('#container').slideDown(); }); $('#using').click(function() { changeContent... }); }
Is there a better way to handle multiple click events, so I don't need an event for every single item. I am sure there should be a way to delegate which item was clicked.
HTML:
<li><a id="about" href="#">About this Application</a></li> <li><a id="using" href="#">Using this Manual</a></li> <li><a id="pages" href="#">Pages:</a></li>
This should be a table of contents for guidance. Thus, there will be many local links.
source share