Snippets Collections
<?php 
    // DP style
    $rules_delete_exception = array();
    $rules_delete_exception[] = 'booker_name {
        required: true
    }';

    $this->formhelper->setupJsFormValidation('confirm_form', '{'.implode(', ', $rules_delete_exception).'}', $messages='{}', $submit_handler='default');
?>

<!-- action button -->
<button type="button" class="btn bg-danger" data-toggle="modal" data-target="#confirm_modal">Confirm</button>

<!-- Modal to confirm action initially hidden -->
<div id="confirm_modal" class="modal fade" tabindex="-1">
    <?php echo form_open('controller/method', array('id' => 'confirm_form')); ?>
        <input type="text" name="booker_name">
            <button type="button" data-dismiss="modal">Close</button>
            <button type="submit">Yes, delete exception</button>
        </div>
    </form>
</div>

<script>
    // Jquery style
    const fv = FormValidation.formValidation(confirm_form, {
        rules: {
            'booker_name', {required: true }
        },

    });
</script>
function verificarEmail() {
  let data = $("#email").serialize();
  $("#errorEmail").text("");
  $.ajax({
    method: "POST",
    url: '/verificarEmail',
    data: data
  })
  .done(function(respuesta) {
    if(respuesta == "Existe"){
      $("#errorEmail").text("El email ya se encuentra registrado.")
    }
   })
  .fail(function() {
    alert( "error" );
  })
}
$.ajax({ 
  type: "POST",
  data: "",
  dataType: 'json',
  url: "",
  success: function(data)
  {

  }
});
$(document).ready(function() 
{
  
});
// SCROLL NAV
jQuery(document).ready(function ($) {
  $(function () {
    var header = $(".navFix");
    $(window).scroll(function () {
      var scroll = $(window).scrollTop();
      if (scroll >= 300) {
        header.removeClass("header").addClass("bg");
      } else {
        header.removeClass("bg").addClass("header");
      }
    });
  });
});
$.ajax({
	type:"POST",
	data:sendstring,
	dataType:'json',
	url:"",
	success:function(data)
	{

    }
});	
<script>
jQuery( document ).ready(function($){
	$(document).on('click','.elementor-location-popup a', function(event){
		elementorProFrontend.modules.popup.closePopup( {}, event);
	})
});
</script>
Basic routing
Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).

Each route can have one or more handler functions, which are executed when the route is matched.

Route definition takes the following structure:

app.METHOD(PATH, HANDLER)
 Save
Where:

app is an instance of express.
METHOD is an HTTP request method, in lowercase.
PATH is a path on the server.
HANDLER is the function executed when the route is matched.
var cardDiv = $("#cards");
var outerDiv = $("<div>", { class: "col-md-4 test" });
        var newDiv = $("<div>", { class: "card mb-3 shadow-sm" });
        var cardsDiv = $("<div>", { class: "card border-success mb-3" });
        var cardImage = $("<img>", { class: "card-img-top" });
        var cardBody = $("<div>", { class: "card-body" });
        var cardTitle = $("<h5>", { class: "card-title" });
        var cardText = $("<p>", { class: "card-text" });
        var cardBtn = $("<button>", { class: "btn btn-primary" });
$.fn.showFlex = function() { this.css('display','flex'); }

$(".element").showFlex();
  $(document).ready(function() {

        $('#check').on('submit', function(e) {
            e.preventDefault();

            $('#sub').prop('disable', true)
            $('#sub').text('Checking');
            $.ajax({
                url: '/home/checkorderstatus',
                method: 'POST',
                contentType: false,
                processData: false,
                cache: false,
                data: new FormData(this),
                success: function(data) {
                    $('#success').slideDown('slow').html(data);

                }
            });


            $(document).ajaxComplete(function() {
                $('#sub').prop('disabled', false)
                $('#sub').html('<i class="fa fa-search"></i>')
                $('#check').trigger("reset");
            })

            setTimeout(function() {
                $('#success').hide('slow')
            }, 3000)
        })


    })
 // scroll animations
    // Select all links with hashes
    $('a[href*="#"]')
        // Remove links that don't actually link to anything
        .not('[href="#"]')
        .not('[href="#0"]')
        .click(function(event) {
            // On-page links
            if (
                location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
                location.hostname == this.hostname
            ) {
                // Figure out element to scroll to
                var target = $(this.hash);
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                // Does a scroll target exist?
                if (target.length) {
                    // Only prevent default if animation is actually gonna happen
                    event.preventDefault();
                    $('html, body').animate({
                        scrollTop: target.offset().top
                    }, 1000, function() {
                        // Callback after animation
                        // Must change focus!
                        var $target = $(target);
                        $target.focus();
                        if ($target.is(":focus")) { // Checking if the target was focused
                            return false;
                        } else {
                            $target.attr('tabindex', '-1'); // Adding tabindex for elements not focusable
                            $target.focus(); // Set focus again
                        };
                    });
                }
            }
        });
     let images = document.getElementsByClassName('thumb-image');
     $('#search_templates').keyup(function (e) { 
         let search = $('#search_templates').val().toLowerCase();
         for (let i = 0; i < images.length; i++) {
             let searchVal = images[i].getAttribute('data-search');
             if (searchVal.toLowerCase().indexOf(search) > -1) {
                 images[i].style.display = "";
             }else{
                 images[i].style.display = "none";
             }
             
         }
         
     });
     
     //#search_templates is input and each image has keywords in data-search="" attribute
$(window).bind("pageshow", function() {
    var form = $('form'); 
    // let the browser natively reset defaults
    form[0].reset();
});
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
    google.load("jquery", "1.2.6");
</script>
<script type="text/javascript" src="js/example.js"></script>
$('#elm').hover(
       function(){ $(this).addClass('hover') },
       function(){ $(this).removeClass('hover') }
)
$("a").hover(function() {
       $(this).stop().animate({paddingLeft : "10px"},200);
},function() {
       $(this).stop().animate({paddingLeft : "0px"},200);
});
$("#slideshow > div:gt(0)").hide();

setInterval(function() { 
  $('#slideshow > div:first')
    .fadeOut(1000)
    .next()
    .fadeIn(1000)
    .end()
    .appendTo('#slideshow');
},  3000);
<div id="kitten" style="background-image: url(dog.jpg);">
  <img src="/images/kitten.jpg" alt="Kitten" />
</div>
$("#more-less-options-button").click(function() {
     var txt = $("#extra-options").is(':visible') ? 'more options' : 'less options';
     $("#more-less-options-button").text(txt);
     $("#extra-options").slideToggle();
});
$("#s")
    .val("Search...")
    .css("color", "#ccc")
    .focus(function(){
        $(this).css("color", "black");
        if ($(this).val() == "Search...") {
            $(this).val("");
        }
    })
    .blur(function(){
        $(this).css("color", "#ccc");
        if ($(this).val() == "") {
            $(this).val("Search...");
        }
    });
if ($('#myElement').length > 0) { 
    // it exists 
}
(function($) {
    
  var allPanels = $('.accordion > dd').hide();
    
  $('.accordion > dt > a').click(function() {
    allPanels.slideUp();
    $(this).parent().next().slideDown();
    return false;
  });

})(jQuery);
jQuery.extend({

  getQueryParameters : function(str) {
	  return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
  }

});
if ($(selectionOne) === $(selectionTwo)) {

}
<div id="slideshow">
   <div>
     <img src="//farm6.static.flickr.com/5224/5658667829_2bb7d42a9c_m.jpg">
   </div>
   <div>
     <img src="//farm6.static.flickr.com/5230/5638093881_a791e4f819_m.jpg">
   </div>
   <div>
     Pretty cool eh? This slide is proof the content can be anything.
   </div>
</div>
<div id="kitten" style="background-image: url(dog.jpg);">
  <img src="/images/kitten.jpg" alt="Kitten" />
</div>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2'></script>
<script type='text/javascript' src='/js/jquery.mousewheel.min.js'></script>
<ul>
  <li>one</li>
  <li>two</li>
  <li>three</li>
</ul>
(function() {
    
    var mX, mY, distance,
        $distance = $('#distance span'),
        $element  = $('#element');

    function calculateDistance(elem, mouseX, mouseY) {
        return Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left+(elem.width()/2)), 2) + Math.pow(mouseY - (elem.offset().top+(elem.height()/2)), 2)));
    }

    $(document).mousemove(function(e) {  
        mX = e.pageX;
        mY = e.pageY;
        distance = calculateDistance($element, mX, mY);
        $distance.text(distance);         
    });

})();
(function($) {
    
  var allPanels = $('.accordion > dd').hide();
    
  $('.accordion > dt > a').click(function() {
    allPanels.slideUp();
    $(this).parent().next().slideDown();
    return false;
  });

})(jQuery);
jQuery.extend({

  getQueryParameters : function(str) {
	  return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
  }

});
// Replace source
$('img').on("error", function() {
  $(this).attr('src', '/images/missing.png');
});

// Or, hide them
$("img").on("error", function() {
  $(this).hide();
});
$('iframe').attr('src', $('iframe').attr('src'));
$.ajax({
  type: "POST",
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
star

Tue Apr 13 2021 19:15:46 GMT+0000 (UTC) https://formvalidation.io/guide/examples/integrating-with-bootbox/

#php #jquery
star

Tue Mar 30 2021 01:18:02 GMT+0000 (UTC)

#ajax #jquery #javascript
star

Mon Mar 29 2021 22:26:41 GMT+0000 (UTC) https://codepen.io/daveredfern/pen/qVJgRo

#html #css #jquery
star

Mon Mar 29 2021 19:49:52 GMT+0000 (UTC)

#javascript #jquery
star

Mon Mar 29 2021 19:48:42 GMT+0000 (UTC)

#javascript #jquery
star

Thu Mar 25 2021 21:13:14 GMT+0000 (UTC)

#jquery
star

Thu Feb 18 2021 17:38:05 GMT+0000 (UTC)

#javascript #jquery
star

Fri Dec 04 2020 01:42:13 GMT+0000 (UTC)

#nodejs #jquery
star

Sat Oct 31 2020 13:00:34 GMT+0000 (UTC)

#jquery
star

Thu Sep 24 2020 16:45:25 GMT+0000 (UTC)

#jquery
star

Fri Aug 14 2020 11:37:34 GMT+0000 (UTC) css-tricks.com

#smoothscroll #jquery
star

Thu Jul 02 2020 03:56:02 GMT+0000 (UTC)

#javascript #jquery
star

Sun Jun 28 2020 10:47:01 GMT+0000 (UTC) https://stackoverflow.com/questions/8861181/clear-all-fields-in-a-form-upon-going-back-with-browser-back-button

#jquery
star

Tue Jun 23 2020 10:05:29 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/loading-jquery/

#jquery
star

Tue Jun 23 2020 09:45:54 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/addingremoving-class-on-hover/

#jquery
star

Tue Jun 23 2020 09:37:32 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/link-nudging/

#jquery
star

Tue Jun 23 2020 09:27:41 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/simple-auto-playing-slideshow/

#javascript #jquery
star

Tue Jun 23 2020 09:06:18 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/fade-image-into-another-image/

#jquery
star

Mon Jun 22 2020 13:00:11 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/toggle-text/

#jquery
star

Wed Jun 03 2020 07:32:34 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/clear-default-search-string-on-focus/

#jquery
star

Wed Jun 03 2020 07:31:02 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/check-if-element-exists/

#jquery
star

Wed Jun 03 2020 07:30:02 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/simple-jquery-accordion/

#jquery
star

Wed Jun 03 2020 07:29:08 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/get-query-params-object/

#jquery
star

Wed Jun 03 2020 07:10:06 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/compare-jquery-objects/

#jquery
star

Wed Jun 03 2020 07:08:41 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/simple-auto-playing-slideshow/

#jquery
star

Wed Jun 03 2020 06:00:01 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/fade-image-into-another-image/

#jquery
star

Wed Jun 03 2020 05:54:07 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/

#jquery
star

Fri May 29 2020 12:29:09 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/move-clicked-list-items-to-top-of-list/

#jquery
star

Fri May 29 2020 12:03:09 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/calculate-distance-between-mouse-and-element/

#jquery
star

Fri May 29 2020 12:00:09 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/simple-jquery-accordion/

#jquery
star

Fri May 29 2020 11:45:11 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/get-query-params-object/

#jquery
star

Fri May 29 2020 11:40:32 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/better-broken-image-handling/

#jquery
star

Tue May 26 2020 11:29:32 GMT+0000 (UTC) https://css-tricks.com/snippets/jquery/force-iframe-to-reload/

#jquery
star

Sat May 09 2020 19:43:38 GMT+0000 (UTC) https://api.jquery.com/jquery.post/

#javascript #jquery
star

Sun May 03 2020 23:24:35 GMT+0000 (UTC) https://makitweb.com/how-to-use-switchclass-and-toggleclass-in-jquery/

#javascript #jquery

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension