Text box ‘hint’ values with jQuery

On creating a rather large form recently, I was in the need to have some kind of hint to the user about what format the content should take on several input boxes. I could have done this with a description under the form element, but a more accepted way to do this, it seems, is to have a ‘hint’ in the element itself. You know the kind of thing I mean; a value, usually quite a light grey colour, that is present until you click in to the form element and then is disappears. I also wanted to do this as a jQuery plug-in because, well, why not? 🙂

Continue reading “Text box ‘hint’ values with jQuery”

Did you like this? Share it:

Highlight external links with jQuery

A little while ago I posted a quick jQuery plug-in that allows you to easily indicate an external link. Then I posted an updated version that had a few optimizations. Well, it turns out that I had missed out a rather important portion of the code when I posted it up. D’oh! So here’s the full and working version.

Continue reading “Highlight external links with jQuery”

Did you like this? Share it:

Simple pleasures with jQuery

Somethings it’s the simple things in life that make you really happy.  For me yesterday, that was thanks to jQuery.  Have you ever wanted to have a check box that, when the user checks it it also checks a lot of other checkboxes?  Yeah, of course you have!  I wanted to do that yesterday.  Now, it’s not the first time I’ve had to do that kind of functionality, but it always came with a bunch of javascript that seemed over the top for what was wanted.  With jQuery it just took a line or two of code!

    $(document).ready(function() {
        $('#selectall').click(function() {
        	$(":checkbox", $('#checkboxlist')).attr('checked', $(this).is(':checked')); 
        });
    });

And with that, on and off go the other checkboxes.

Marvelous!

Did you like this? Share it:

jQuery plug-in – highlight external links

I’m pretty new to the whole jQuery game, having really only started to look at in a number of weeks ago. Until then I have been happily using Prototype and Scriptaculous, and as I knew them I didn’t see a point to move to another library. However, the more examples I saw of jQuery the more elegant I thought it was, and so now am in the process of learning it more, converting some code over and trying my hand at plug-ins. So here’s introducing my first jQuery plug-in!

This plug-in allows you to automatically append a class and title to any external resources. You can pass in multiple domains that are thought of as ‘local’, and anything else with a protocol that doesn’t belong on the passed local domains will be flagged as external. If no domains are passed then the current domain in the url will be used as-is (with the www., etc., if present).

That probably doesn’t make much sense, but I’m sure it will when using it…

So here’s the code:

Continue reading “jQuery plug-in – highlight external links”

Did you like this? Share it:

Same height for elements

Surely this is easy, right? Just set the height property in your css. Well, yes and no. That’s all well and good if you know what height the elements are going to be, but quite often you might be pulling information out of a database in to the elements and you don’t know how big that information is going to be. You can’t use the overflow because that’s not the designer’s concept. No; they want three boxes on screen that all have the same height so they’re all nice and ordered and symmetrical.

Continue reading “Same height for elements”

Did you like this? Share it: