Skip to main content

Posts

Showing posts from December, 2008

How to disable/enable an element with jQuery

Sometimes you need to disable or enable some elements in your document and jQuery makes this task easy. All you have to do is to set disabled attribute to "disabled". Example: // To disable $('.someElement').attr('disabled', 'disabled'); In order to enable any disabled element you need to set the disabled attribute to empty string or remove it entirely like in the code below. // To enable

How to disable/enable an element with jQuery

Sometimes you need to disable or enable some elements in your document and jQuery makes this task easy. All you have to do is to set disabled attribute to "disabled". Example: // To disable $('.someElement').attr('disabled', 'disabled'); In order to enable any disabled element you need to set the disabled attribute to empty string or remove it entirely like in the code below. // To enable

Caching in jQuery

What is great about jQuery is its simplicity in selecting elements. We all use it here and there, basically everywhere. This simplicity comes with its drawbacks. jQuery traverses through all elements every time we use selectors. So to boost up your jQuery application you should always cache your selections to some variable (if you find yourself using the same selection more than once). In case

Caching in jQuery

What is great about jQuery is its simplicity in selecting elements. We all use it here and there, basically everywhere. This simplicity comes with its drawbacks. jQuery traverses through all elements every time we use selectors. So to boost up your jQuery application you should always cache your selections to some variable (if you find yourself using the same selection more than once). In case

How to check if checkbox is checked using jQuery

Note: If you are new to jQuery, you might find our short jQuery beginner tutorials useful. While working on my previous project I needed a way to check if the certain checkbox is checked or not. jQuery is a great library but I had a hard time identifying if any particular checkbox was checked. So here is the way to do just that. All you need to do is to check checked attribute of checkbox HTML

How to check if checkbox is checked using jQuery

Note: If you are new to jQuery, you might find our short jQuery beginner tutorials useful. While working on my previous project I needed a way to check if the certain checkbox is checked or not. jQuery is a great library but I had a hard time identifying if any particular checkbox was checked. So here is the way to do just that. All you need to do is to check checked attribute of checkbox HTML

How to test JavaScript code performance

Sometimes after all day long coding your code becomes not so effective and your code (usually interface related) becomes slow. You have done so many changes and don't exactly know what slowing it down. In cases like this (and of course, plenty other cases) you can test your JavaScript code performance.  First of all, you need Firefox browser and Firebug web developers life saver plugin. I can not

How to test JavaScript code performance

Sometimes after all day long coding your code becomes not so effective and your code (usually interface related) becomes slow. You have done so many changes and don't exactly know what slowing it down. In cases like this (and of course, plenty other cases) you can test your JavaScript code performance.  First of all, you need Firefox browser and Firebug web developers life saver plugin. I can not

Everything has characteristics of an Array in JavaScript

The title maybe a little misleading. So don’t confuse Arrays with Object in JavaScript! They have common and non-common methods. You can use jQuery built-in method to check if any given variable is an array ($.isArray(var)). I came across this feature of JavaScript recently and thought I would share it with you. So every object I tried to use had capabilities of array. I could refer to object/

Everything has characteristics of an Array in JavaScript

The title maybe a little misleading. So don’t confuse Arrays with Object in JavaScript! They have common and non-common methods. You can use jQuery built-in method to check if any given variable is an array ($.isArray(var)). I came across this feature of JavaScript recently and thought I would share it with you. So every object I tried to use had capabilities of array. I could refer to object/

What a heck is a (function ($){ ... })(jQuery)

Recently I wrote two articles on how to extend jQuery using its plug in system and a shorthand for that. If you look into them closely they are actually the same thing. The only difference being that the code in first one is wrapped in this anonymous JavaScript function: (function ($) { // code goes here })(jQuery) Little research shows that this allows the use of $ within this function

What a heck is a (function ($){ ... })(jQuery)

Recently I wrote two articles on how to extend jQuery using its plug in system and a shorthand for that. If you look into them closely they are actually the same thing. The only difference being that the code in first one is wrapped in this anonymous JavaScript function: (function ($) { // code goes here })(jQuery) Little research shows that this allows the use of $ within this function

How to add your own custom functions to jQuery

Recently I wrote a template on how to extend jQuery and how to create your own functions. Since then I came across even smaller code snippet on how to add your own custom functions, in other words how to create plugins for jQuery. So without further ado: $.fn.myFunction = function() { return $(this).addClass('changed'); } And now, use it like this: $('.changePlease').myFunction(); And that

How to add your own custom functions to jQuery

Recently I wrote a template on how to extend jQuery and how to create your own functions. Since then I came across even smaller code snippet on how to add your own custom functions, in other words how to create plugins for jQuery. So without further ado: $.fn.myFunction = function() { return $(this).addClass('changed'); } And now, use it like this: $('.changePlease').myFunction(); And that

Let Google host your jQuery library

Google hosts several JavaScript libraries such as Prototype, script.aculo.us, MooTools, Dojo, etc. It also hosts jQuery, as well as jQuery UI. The files are already minimized, gzipped and if your visitors have already visited some site that loaded jQuery from Google Code then it already be on user's machine. So there is nothing to load. UPDATE: You can also use jQuery hosted by Microsoft CDN

Let Google host your jQuery library

Google hosts several JavaScript libraries such as Prototype, script.aculo.us, MooTools, Dojo, etc. It also hosts jQuery, as well as jQuery UI. The files are already minimized, gzipped and if your visitors have already visited some site that loaded jQuery from Google Code then it already be on user's machine. So there is nothing to load. UPDATE: You can also use jQuery hosted by Microsoft CDN

How to bind events to AJAX loaded elements

We all use jQuery's AJAX helpers like $.get(), $.post() and $.load(). We also all use jQuery's event bindings. When you use them both, problems such as your event bindings like click() are not bided to your new AJAX loaded elements. To solve this problem you need to bind events to your newly loaded elements. NOTE: Make sure you don't bind the same event to the elements with this event

How to bind events to AJAX loaded elements

We all use jQuery's AJAX helpers like $.get(), $.post() and $.load(). We also all use jQuery's event bindings. When you use them both, problems such as your event bindings like click() are not bided to your new AJAX loaded elements. To solve this problem you need to bind events to your newly loaded elements. NOTE: Make sure you don't bind the same event to the elements with this event

How many elements were selected by jQuery

Recently I needed to find out how many elements were selected by jQuery. jQuery selector returns an array of elements jQuery object that has .length attribute. So the easiest way is to get the length of returned jQuery object. The size of that object will be equal to the number of selected elements. $('.someClass').length; // Assume you have 4 .class elements $('.class').length; // would return

How many elements were selected by jQuery

Recently I needed to find out how many elements were selected by jQuery. jQuery selector returns an array of elements jQuery object that has .length attribute. So the easiest way is to get the length of returned jQuery object. The size of that object will be equal to the number of selected elements. $('.someClass').length; // Assume you have 4 .class elements $('.class').length; // would return

Access to restricted URI denied" code: "1012

I was working on the interface for our catalogue/directory structure. We use great JavaScript library jQuery as our JS framework. While working on page AJAX requests to get child categories I came up to this error message / problem: Access to restricted URI denied" code: "1012 xhr.open(type, s.url, s.async); (This error was produced in Firebug, plug-in for Firefox) The error occurs when my

Access to restricted URI denied" code: "1012

I was working on the interface for our catalogue/directory structure. We use great JavaScript library jQuery as our JS framework. While working on page AJAX requests to get child categories I came up to this error message / problem: Access to restricted URI denied" code: "1012 xhr.open(type, s.url, s.async); (This error was produced in Firebug, plug-in for Firefox) The error occurs when my

Wonton Wrappers

Wonton Wrappers is the basic ingredients of many Wonton Recipe from Chinese Food . Wonton wrappers can be bought at the Asian Groceries Store or Supermarkets . But making your own Wonton wrappers at home isn't impossible and not too complicated also quick prepare . Here's a Wonton Recipe to help you serving your own making Wonton Recipes . Wonton Wrappers Recipe ( Makes about 3 dozen squares) Ingredients : 1 large egg white About 1/3 C water 1 C all-purpose flour 1/4 teaspoonful salt Cooking Direction : Combine the flour and salt In the bowl of a standing mixer (or use a hand mixer) Add the egg white and mix with the paddle attachment over medium speed, Slowly adding water until the dough forms a ball. (Use all the water if needed) Continue beating the dough with the paddle for several minutes, or remove from the mixer to knead by hand. ( Adjust the flour and/or water content by increments as necessary till it form a smooth elastic dough that isn’t sticky ). Cut the dou