jQuery remove empty element from an array — December 4, 2017

jQuery remove empty element from an array

let say you have this array

var basisList = ['lorem', ,'ipsum'];

and you want to remove that empty element then just use this

basisList = basisList.filter(Boolean);

result will be

['lorem','ipsum']
Advertisements
jQuery check and make sure that function exists — November 13, 2017
jQuery allow only digits in input — September 4, 2017

jQuery allow only digits in input

jQuery.fn.ForceNumericOnly =function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
            // home, end, period, and numpad decimal
            return (
                key == 8 || 
                key == 9 ||
                key == 13 ||
                key == 46 ||
                key == 110 ||
                key == 190 ||
                (key >= 35 && key = 48 && key = 96 && key <= 105));
        });
    });
};

$("#userphone").ForceNumericOnly();

jQuery Datatable fix header — July 11, 2017

jQuery Datatable fix header

need to add these two files

http://cdn.datatables.net/fixedheader/2.1.1/css/dataTables.fixedHeader.css
http://cdn.datatables.net/fixedheader/2.1.1/js/dataTables.fixedHeader.min.js

and this

var table = jQuery('#datatable').dataTable({});
new $.fn.dataTable.FixedHeader( table, {
    // alwaysCloneTop: true
    // "zTop": "2001"
    "offsetTop": 50
});

You can check more options here.

jQuery datatable multiple column sort — July 5, 2017
jQuery Datatable change column orders —
jQuery Wysiwyg does not work after .load() — February 19, 2017