Recent Posts

Toggle DIV element using jquery

What is Toggling?
Basically a show/hide feature for your webpage elements. For example, you may have a login box in your webpage, and you want your visitors to click on a button for showing or hiding the element.

This tutorial will show you how to implement a simple toggle effect in your webpage using jQuery.

As always, we will require some HTML content first

  1.  
  2. <a id="clickMe">Toggle my text</a>
  3. <br />
  4. <div id="textBox">This text will be toggled</div>

jQuery code
This is the code that makes the 'textBox' element toggle

  1. $("#textBox").toggle();
read more...
Change DIV content using jQuery

This is a quick tutorial for understanding the basics of jQuery.

Create a new HTML file with this code:

  1. <html>
  2.   <head>
  3.     <title>jQuery test page</title>
  4.     <script type="text/javascript" src="jquery.js"></script>
  5.     <script type="text/javascript">
  6.     // javascript here (jQuery)
  7.     </script>
  8.   </head>
  9.   <body>
  10.     <--- HTML content here -->
  11.   </body>
  12. </html>

Right now, the page will just load the jQuery library.

Lets get some HTML content first

  1. <a id="changeText">Change my text</a>
  2. <br />
  3. <div id="textBox">
  4.   This text will be changed to something else
  5. </div>
read more...
Change or set HTML tag attribute using jQuery

It is sometimes necessary to change the attributes of a particular HTML tag of your webpage using javascript, especially when you are coding rich web applications. Let it be the class of an element, or the href attribute of an anchor tag.

In this tutorial, I am going to show you how to do it utilizing jQuery javascript library quickly.

HTML code (inside BODY tag)
First, we will place a sample image and a link in our webpage.

  1. <a id="clickMe" href="#">Change the image below</a>
  2. <br />
  3. <img id="myimage" src="current_image_file.jpg" />

Now we want the src attribute to change from current_image_file.jpg to new_image_file.jpg (a click event will be required).

read more...
Switch CSS stylesheets using jQuery

CSS Stylesheet Switcher - what does it mean?
A stylesheet switcher allows your visitors to choose from a number of stylesheets they would like to view your website with. For example, you may have three pre-made stylesheets (say red, blue and green) and you want your visitors to choose and apply any one of them in your webpage without redirecting them to a new page or refreshing the page.

This tutorial will show you how to create such a client side css stylesheet switcher using jQuery javascript library.

read more...
Cheat Sheet Collection

Its very natural that you are developing a website and have forgotten an important function of php, or a property of cascading style sheet. Cheat sheets can come handy in such situation providing you the information you are looking for. Here is a list of useful cheat sheets. More will be added.

read more...