JSFiddle

  • Check if all number in array are primes

    Based on module pattern with simple unit test.

    "use strict";
    
    var Primes = (function() {
    
      var isPrime = function(value) {
        for (var i = 2; i < value; i++) {
          if (value % i === 0) {
            return false;
          }
        }
        return value > 1;
      };
    
      var areAllPrimes = function(arr) {
        var ...
  • Pure JS reveal sibling example

    No-Library (pure JS), HTML, SCSS, JavaScript

    document.body.addEventListener("click", function(event) {
      if (event.target.nodeName === 'H1') {
        event.target.nextElementSibling.style.display = "inline";
      }
    });
    
  • Bounce element in viewport

    On scroll bounce some elements in viewport

    var $animation_elements = $('.animation-element');
    var $window = $(window);
    
    function check_if_in_view() {
      var window_height = $window.height();
      var window_top_position = $window.scrollTop();
      var window_bottom_position = (window_top_position + window_height ...
  • Animate element on scroll

    CSS Animation on jQuery Scroll

    $(function() {
      var element = $(".element");
      var i = 0; //fix for first scroll
      $(window).scroll(function() {
        var scroll = $(window).scrollTop();
    
        if (scroll ...
  • canvas parlament circle

    the division of parliament

    //define
    var deputies = 460; //how many deputies
    var radius = 450;
    var x0 = 500;
    var y0 = 500;
    var rows = deputies/10 ...
  • Filtrowanie obiektów #4 is the latest revision

    Filtrowanie i wyświetlanie danych z obiektów

    var d = document.getElementById('lista');
    var student = [{
      imie: "Ola",
      nazwisko: "Kowal",
      kierunek: "fizyka"
    }, {
      imie: "Ela",
      nazwisko: "Nowak",
      kierunek: "fizyka"
    }, {
      imie ...
  • Animowane logo

    Kółko na hoverze obracane o 360 stopni css-em

    <div class="img"></div>
  • Datepicker disable past and future dates #4 is the latest revision

    jQuery 1.9.1, HTML, CSS, JavaScript, jQuery UI 1.9.2

    var dateToday = new Date();
    var dates = $("#date").datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 2,
        minDate: dateToday,
        maxDate: dateToday
    });
  • Sum/count checkboxes value and print it out #9 is the latest revision

    Sum price from checked checkboxes with custom data attribute.

    /*
        basicPrice - podstawowa cena
        dataPrefix - nazwa atrybutu data z ktorego zaciagamy ceny
        place - wskaźnik jquery na element wyświetlajacy cene
    */
    var basicPrice ...
  • Google Maps Custom Pin Location

    This example highlights random intersections within Nassau County Long Island.

    /* Place the locations array into a separate JS if you want */
    /* The ordering : Main Street, Cross Street, Camera Direction, Latitude ...