Wednesday, December 7, 2011

Wrote my first jquery plugin it strips out html for an input field

I needed a way to remove up html from my input from the users.  This is my first attempt at it.
(function ($) {
 
    $.fn.safeVal = function () {
        var value = $(this).val();
        var ret = $('<div>').html(value).text();
        return ret;
    };
})(jQuery);