JSFiddle

  • Countdown #3 is the latest revision

    Countdown until zero.

    var split = form.cronometro.value.split(':')
    var numCount = split.map((el) => parseInt(el))
    var addZero, clearInt
    
    document.querySelector('button').addEventListener ...
  • Deck of Cards - JavaScript Generate a card

    Generate random cards with JavaScript.

    const $ = document.querySelector.bind(document)
    const Card = function() {
      return {
        suit: [{
          name: 'Hearts',
          symbol: '♥'
        }, {
          name: 'Clubs',
          symbol: '♣'
        }, {
          name: 'Spades',
          symbol: '♠'
        }, {
          name ...
  • Order numbers without sort using map and filter ES6

    Order numbers without sort javascript function. Using feature ES6 map, filter, arrow functions. And tidy all with closuje.

    let $ = document.querySelector.bind(document)
    
    const Bm = {
      num: {
        convert(numbers) {
          return numbers.map((item, position, array) => {
            array[position] = typeof array ...
  • Validate a form replace spaces on keyup.

    Replace spaces and copy field values to anothers form by name.

    var formCadastro = '.cadastro';
    var mktoForm = '#mktoForm_1289';
    var propInput = 'input[name]';
    var textinput = document.querySelectorAll(propInput);
    var str = /\s\s+/g ...
  • Mascara e validação de CPF

    Insere mascara e valida se o CPF é válido pelo digito verificador. Cria uma máscara para o telefone com o 9 digito.

    $(function() {
    	// Mascara de telefone
    	jQuery('input[name="telefone"]').on('keyup blur', function(event) {
    		jQuery(this).attr({ maxLength : 15 });
    		jQuery(this ...
  • Sort numbers without sort function

    Get and filter numbers with pure JavaScript without sort function.

    // ATTENTION
    // I have been using ECMA6
    // If you will put it on your website. Transpile it!
    let $ = document.querySelector.bind ...
  • Thousand separator number

    Separate thousand number and toFixed decimal.

    /* 
     ** SUBSTITUI PONTOS E VIRGULAS DO VALOR INICIAL
     */
    var convertToFloatNumber = function(value) {
    	// CONVERTE O VALOR RECEBIDO EM STRING
        value = value.toString ...
  • Remove object by id

    Remove an element from object passing an id to it.

    const remove = document.querySelector('input[type="number"]');
    const btnRemove = document.querySelector('button');
    let obj = [{
    		"id": 1,
    		"project": "product"
    	}, {
    		"id": 2 ...
  • Get Query Params with JS

    Get Href Params using JavaScript

    function getQueryParams(qs) {
        qs = qs.split('+').join(' ');
    
        let params = {},
            tokens,
            re = /[?&]?([^=]+)=([^&]*)/g;
    
        while (tokens = re.exec(qs)) {
            params[decodeURIComponent(tokens[1 ...
  • ScrollTo without jQuery

    ScrollTo without jQuery and use ECMA6

    var Fn = function() {
        return {
            init: function() {
                this.pageEffects.init();
            },
            pageEffects: {
                init: function() {
                    this.scrollToClick();
                },
    
                scrollTo: function(body, to, duration) {
                    let ...