Frage

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!

War es hilfreich?

Lösung

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 ));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top