Javascript



How to delay the .keyup() handler until the user stops typing?
function delay(callback, ms) {
    var timer = 0;
    return function() {
        var context = this, args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            callback.apply(context, args);
        }, ms || 0);
    };
}


// Example usage:

$('#input').keyup(delay(function (e) {
  console.log('Time elapsed!', this.value);
}, 500));
How to stop chrome from going into debug mode?
You've accidentally set "Pause on Exceptions" to all/uncaught exceptions.

Go to the "Sources" tab.
At the bottom toolbar, toggle the button that looks like the pause symbol surrounded by a circle (4th button from the left),
until the color of the circle turns black to turn it off.
Nombre de caractères différents dans une chaine
var nbDiffCaract = myString.split('').filter(function(el, index, arr) {
    return index == arr.indexOf(el);
}).length;
To select all elements that have classes x, y, and z
.x.y.z
To select all elements that have classes x, y, or z
.x, .y, .z
To select all elements that have class x but not classes y or z
.x:not(.y):not(.z)
To select all elements that aren’t DIV elements
:not(div)
To select all DIV elements that don’t have class x
div:not(.x)
To select all DIV elements that don’t have class x but do have class y
div:not(.x).y
To select all elements that are not DIVs and not of class x
:not(div):not(.x)
To select all y elements that have an ancestor x element
.x .y
To selects all y elements that don’t have a parent x
:not(.x) > .y
Find all x elements that do contain another element of type y
Array.from(document.querySelectorAll(“.x”)).filter(item => !!item.querySelector(“.y”));
Find all x elements that don’t contain another element of type y (the only difference is the not [!])
Array.from(document.querySelectorAll(“.x”)).filter(item => !item.querySelector(“.y”));
c is undefined
  • manque <thead> et/ou <tbody>
  • mauvais nombre de <td> et/ou <th>