Skip to content

Instantly share code, notes, and snippets.

@jordanneenan
jordanneenan / v-align.js
Created March 2, 2016 05:28
Vertically align element to the middle of its parent
//vertically align element to the middle of its parent
function vAlign(){
if(jQuery('.v-align').length){
var jQueryvaChild = jQuery('.v-align');
jQueryvaChild.each(function(){
var vaChildHeight = jQuery(this).height();
var vaParentHeight = jQuery(this).parent().height();
var topOffset = (vaParentHeight - vaChildHeight) / 2;
jQuery(this).css('paddingTop', topOffset).addClass('show');
});
@jordanneenan
jordanneenan / custom-checkbox.js
Created February 22, 2017 02:31
Custom checkbox with javascript
$(document).ready(function(){
//hide the checkboxes
$('.ginput_container_checkbox li input').hide();
//inject the custom checkbox code
$('.ginput_container_checkbox li input').before('<div class="custom_checkbox"><div class="check_inner"></div></div>');
//control the new checkbox on click
$('.ginput_container_checkbox li').on('click', '.custom_checkbox', function(){