سؤال

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!

هل كانت مفيدة؟

المحلول

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 ));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top