Advertise here


Tag cloud


 

You are currently browsing the archives for the JavaScript category.

Archive for the ‘JavaScript’ Category

Execute script after images have loaded in

Posted on Thursday, May 19th, 2011 in JavaScript

I found myself needing to run a script to make minor adjustments to the page based on the size of an image, to keep things tidy. The problem I was having was using JQuery’s $(document).ready the script was executing as soon as the DOM was ready which is too early. The other option is to use $(window).load which runs only when the whole page has loaded, guaranteeing that I will get the image width and I can make my adjustments. The script below is used to make the image caption the same width as the image.

$(window).load(function () {
    imgWidth = $("#mainImg").attr("width");
    var caption = $(".imgCaption");
    if (imgWidth < 300) {
        captionWidth = imgWidth - (parseInt(caption.css("padding-left")) + parseInt(caption.css("padding-right")));
        caption.css("width", captionWidth+"px");
    }
});

Hiding rows in a table using JQuery

Posted on Thursday, October 28th, 2010 in JavaScript

I was writing a simple JQuery script which filters out table rows based on class name.  When I used visibility:hidden; I noticed that when it was made visible again, the table looked slightly broken. To fix this instead of using visibility:hidden use visibility:collapse; and this keeps the table format correct when it is made visible again.
Read more


JQuery AJAX Query creator

Posted on Monday, June 7th, 2010 in JavaScript

This is a useful script that I have written that uses the JQuery library, so don’t forget to include it above this script. It collects all the form data from all the different form types and formats into a query string to pass through the AJAX method (JQuery or your own). It behaves in the same way as the GET method for example if a checkbox is not selected the data is not sent and it can filter which radio form has been selected. Read more



Web Design Essex | Richard Kotze – Web Technology, Design and Development powered by WordPress | Entries (RSS)