CodeHQ

Archive for the ‘jQuery’ Category

« Older Entries |

Create your own social share buttons

Friday, February 22nd, 2019

Add this HTML for the buttons:
(Download HTML here)

Add this javascript for the button popup function:

function newPopup(url) {
	popupWindow = window.open(
url,'popUpWindow','height=450,width=600,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}

Tags: , , , , , , , , ,
Posted in HTML, jQuery | No Comments »

Find elements on page by their CSS Properties

Tuesday, February 12th, 2019

Drop this in to your console in dev tools and all elements with position: absolute will render with a border.

var absElements = [];
$("*").css("position", function(i, pos){
   if(pos==="absolute") absElements.push(this);
});

$(absElements).css({border:"5px solid red"});

Tags: , , , , , , ,
Posted in CSS, jQuery | No Comments »

Remove spaces in tel href links

Wednesday, August 29th, 2018

/* Remove all spaces in tel: href links so click to call works */
$('a[href^="tel:"]').attr('href', function(_,v){
    return v.replace(/\(0\)|\s+/g,'')
});

Tags: , , , , , ,
Posted in jQuery | No Comments »

Cross-browser horizontal mousewheel scroll

Wednesday, June 14th, 2017

See the Pen Cross-browser horizontal mousewheel scroll by Matt Seymour (@mwseymour) on CodePen.

Tags: , , ,
Posted in jQuery | No Comments »

jQuery in the footer

Thursday, December 1st, 2016

Add this to your functions.php

function my_init()   
{  
    if (!is_admin())   
    {  
        wp_deregister_script('jquery');  
  
        // Load a copy of jQuery from the Google API CDN  
        // The last parameter set to TRUE states that it should be loaded  
        // in the footer.  
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', FALSE, '1.11.0', TRUE);  
  
        wp_enqueue_script('jquery');  
    }  
}  
add_action('init', 'my_init');  

Tags: , , , , ,
Posted in jQuery, PHP, WordPress | No Comments »

Vanilla List: The Vanilla Javascript Repository

Friday, June 3rd, 2016

Tags: , , , ,
Posted in jQuery | 1 Comment »

Scroll to anchor | Javascript

Monday, April 11th, 2016

$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 800);
        return false;
      }
    }
  });
});

Tags: , , , , ,
Posted in jQuery | No Comments »

unorphan.js | Prevents text orphans | jQuery

Friday, December 11th, 2015

A jQuery method to remove text orphans from any element you declare. Light-weight and easy to use!

$(function() {
    unorphan($('p, h1, h2, h3, h4'))
});

Tags: , ,
Posted in jQuery | No Comments »

Equal Heights of columns with jQuery

Friday, June 5th, 2015

Tags: , , , ,
Posted in jQuery | No Comments »

Priority navigation

Thursday, May 7th, 2015

Tags: , , , ,
Posted in CSS, HTML, jQuery | No Comments »

Next Page »