jQuery logo

There are 5 buttons on a page. If you click 1, 3 or 4 there must be one action, for 2 and 4 another one. You don’t have to write the same action for each control, like this:

Of course, it’s not comfortable and compact record.

You can easily improve the code with 'add()' method.

There’s also another way to write the code, but it’s not universal. You can use it only when you know IDs of buttons.

With method ‘add()’ you can use variables to get controls.