powered by Slim Framework
enhanced by Nesbot.com

JavaScript: Set Cursor Position of textarea

Published on Feb 13, 2012 by Jamie Munro

Probably not required often, but you just never know when you might need to set the cursor position inside a textarea tag that you have on your website.  Perhaps you want to add a button that will insert some text before the current cursor position and set the cursor back to where the user left it afterwards.  In the following example, I will create some basic functions to allow you to set where the cursor goes inside of a textarea.

Read more >

Tags: Javascript

jQuery: Padding a Variable or String with a Specific Character

Published on Jan 30, 2012 by Jamie Munro

Every so often you will receive data from a database or potentially user input, but a specific number of characters might be required to format or display the data properly.  As an example, you may wish to ensure that a number less than 9 is prefixed with a 0 where numbers that are 10 or more do not need the padding.  By extending jQuery, two functions can be created to either prefix or postfix a specific value to a DOM element using a jQuery selector.

Read more >

Tags: Javascript | jquery

jQuery: Creating Your Own Selector

Published on Jan 16, 2012 by Jamie Munro

By default, the jQuery selectors are pretty advanced.  You can select items by classes, ids, attributes, the first, the last, etc…  But why stop there?  By simply extending jQuery, we can add our own custom selectors to further enhance how we use jQuery.

Read more >

Tags: Javascript | jquery

jQuery: Checking if an element exists

Published on Jan 2, 2012 by Jamie Munro

You want to do some conditional processing depending on if an item or items exist in your DOM (Document Object Model).

Read more >

Tags: Javascript | jquery

jQuery: Implementing a callback

Published on Dec 19, 2011 by Jamie Munro

As we move into a more and more interactive era of website development, more of the JavaScript work is being done asynchronously and not "top-down".  This can provide some interesting challenges, for example, executing a specific action after a specific process has been completed – also known as a callback.  Thankfully, jQuery provides some useful functions to help with this process.

Read more >

Tags: Javascript | jquery