Introduction

In this article, we will learn about jQuery Interaction. jQuery offers 5 kinds of interactions. All are mouse-based and can be used in combination to provide easy interaction for users. This article will cover all the five jQuery UI interactions and it'll use the source file of the Part 1 article. So if you haven't had a look at Part 1 then you have two options.
The first is you can continue with this article or you can have a look at Part 1.
A quick overview of Part 1
In Part 1 we learned how to add a widget on any HTML element. In brief it is like:
$(element_to_target).widget_name({List_of_options});
If we dismantle this line of code then we have the following to learn:
  1. $ - It is a valid JavaScript identifier or variable name and it's a shorthand notation for writing jQuery. For instance, the following two code samples represent the same thing.
    code1:jQuery('.test').tooltip();
    code2:$('.test').tooltip();
  2. $(element_to_target) - Here the mystery is in shorthand. If we replace the $ with jQuery then it will look like this: jQuery('element_to_target'). Oh, guess what it is! It looks like nothing but a function call where "element_to_target" is a parameter passed to a function. In a nutshell, it represents a function call that wraps the element_to_target into a jQuery object.
  3. .widget_name() - It is used for setting a particular widget on that object.
For examples and more details, you can check Part 1 of this article.
Working with jQuery Interactions

Draggable

Droppable

Resizeable

a3p3.jpg

Selectable

Sortable

Summary

All done. It's time to check out what we have learned so far. We learned about jQuery Interaction. We uncovered the secrets behind $. (It's a symbol that is important in real life as well as in web development so stick it into your brain). We covered all five of the interactions available in jQuery. We have seen how easy it is to use them. We saw examples of each interaction. In conclusion, it is important to understand when to use each interaction. If you use them wisely then your page will definitely be blessed by jQuery. Don't stop only on this now, you have the launch pad ready for diving into the jQuery Docs.
In Part 3 we will learn about the effects and how to use them in a simple and effective way.
Thanks for reading this article. Don't forget to comment. Like is optional but good to have. :)
Live demo