Archive

Archive for the ‘JavaScript’ Category

When you need jQuery (or Bootstrap), but fast!

February 24th, 2012 No comments

I sometimes need to test some jQuery locally and I’m never organised enough to have a template ready. The latest version from a CDN is all I need and googling for the URL or searching my bookmarks will take longer than the solution I came up with today.

Before:

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”
type=”text/javascript”></script>

After:

<script src=”http://is.gd/jQuery” type=”text/javascript”></script>

I’m hoping that if I use it enough times, I’ll remember it! If you use this tip, make sure you don’t copy paste this onto your production systems. You could do without the one extra request to is.gd

Edit: I’ve added a URL for Bootstrap, from Twitter. It is:
Before:

<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css"
rel="stylesheet" />

After:

<link href="http://is.gd/Bootstrap" rel="stylesheet" />

Setting equal CSS heights using jQuery.

July 2nd, 2009 No comments

I recently needed to do this and found a solution over at filament group, however, I wanted the flexibility to specify the elements to work with.

This is what I came up with:

(function($) {
    $.equalHeight = function(element) {
        var maxHeight = 0;
        $.each(element, function() {
            if ($(this).height() > maxHeight) {
                 maxHeight = $(this).height();
            }
        });
        $.each(element, function() {
            $(this).height(maxHeight);
        });
    }
})(jQuery);

And an example of usage:

var obj = {
    one:$("#pinned .content"),
    two:$("#top10 .content")
};
$.equalHeight(obj);

Demo:







Categories: All, JavaScript, Web
Tags: ,