Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a basic plugin using jquery

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 235
    Comment on it

    If you want to make a functionality that can be used anywhere in the code. For example, you want some method that can be called on the jquery selection and it can perform number of operations on the selection. For this, you can write a plugin.

    For example if we want to create a plugin that makes color of the text red within set of elements(p, span, a). Then we have to add a function named method1 to $.fn and it will work as other jquery object methods.

    $.fn.method1 = function() {
        this.css( "color", "red" );
    };
    
    $( "p" ).method1(); 
    $("span").method1();
    $("a").method1();
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: