Question

I have made this simple function that add placeholders to browsers that do not support them by default, like Explorer 8.

DEMO

The question is: How can i make a plugin with that function? In order to remove the code from the html file and put it in a separate js file?

Thank you!

Était-ce utile?

La solution

Just so you know: there is already a plugin for that.

JQuery UI has a nice learning center.

Basic example from learning center above:

(function ( $ ) {

    var shade = "#556b2f";

    $.fn.placeholder = function() {
        // your code
        return this;
    };

}( jQuery ));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top