Showing posts with label jquery plugin tutorials. Show all posts
Showing posts with label jquery plugin tutorials. Show all posts

Wednesday, May 21, 2014

How to make jQuery Plugin. Let's do that!

<script>
        // Like Function, There is no selector
        jQuery.reload = function () {
            location = location;
        };

        $(document).ready(function () {
           $.reload();
        });

        // It has selector, normal plugin
          jQuery.fn.myPluginMethod = function (options) {
            $(this).css('color', 'White');
            $(this).css('background', 'Black');
        };

        $(document).ready(function () {
          $('h1').myPluginMethod();
        });
</script>
Hi~! Today we make jquery plugin.
There is two way. That have selector or not.


- Make -
First.
jQuery.pluginName = function () {
};
It doen't have selector.

Second.
jQuery.fn.pluginName = function(options) {
};
It has selector.

- Use -
First.
$.pluginName();

Second
$(selector).pluginName();

We can use this two way.

That's it!
We can make jquery plugin~^^
Let's Coding~~~~~~~~!!