JSFiddle - React, Tailwind, and code Playground

jQuery Plugins and jQuery UI Widgets

by Terry Young

HTML

<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.14/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.14/themes/black-tie/jquery-ui.css">
<input type="text" id="test" />

JavaScript

$.widget("ui.tester", {
    _init: function() {
        console.info(arguments);
        console.info(this);
        console.info(this.options);
        /*
        var $el = this.element;
        $el.datepicker(this.options);
        
        if (this.options && this.options.trigger) {
            $(this.options.trigger).bind("click", function () {
                $el.datepicker("show");
            });
        }
        */
    }
});


(function ($) {
	$.fn.texter = function (settings) {
		var defaults = {
				clear:            true,
				replacementRegex: /([^0-9])/,       
				replacementChar:  '',               
				convertCase:      1                 
			},

			options = $.extend(true, {}, defaults, settings);

		this.each(function () {			
			var $this = $(this);
			if ($this.is('textarea') || $this.is('input:text')) {
				$this.on('keydown', function (event) {
                    console.info(event.which);
                });
            }
        });
    }
})(jQuery);


$('#test').texter();