HTML/CSS Service

Why we use jQuery?

Category: Learn jQuery    |    1,027 views    |    1 Comment  |   

jQuery is ideal because it can create impressive animations and interactions. jQuery is simple to understand and easy to use, which means the learning curve is small, while the possibilities are (almost) infinite.

Javascript and Best Practices

Javascript has long been the subject of many heated debates about whether it is possible to use it while still adhering to best practices regarding accessibility and standards compliance.

The answer to this question is still unresolved, however, the emergence of Javascript frameworks like jQuery has provided the necessary tools to create beautiful websites without having to worry (as much) about accessibility issues.

Obviously there are cases where a Javascript solution is not the best option. The rule of thumb here is: use DOM scripting to enhance functionality, not create it.

Unobtrusive DOM Scripting

While the term “DOM scripting” really just refers to the use of scripts (in this case, Javascripts) to access the Document Object Model, it has widely become accepted as a way of describing what should really be called “unobtrusive DOM scripting”—basically, the art of adding Javascript to your page in such a way that if there were NO Javascript, the page would still work (or at least degrade gracefully). In the website world, our DOM scripting is done using Javascript. Read more…

Share/Save/Bookmark

 

MooTools Dropdown Menu

Category: Learn jQuery    |    1,297 views    |    Add a Comment  |   
The UvumiTools Dropdown Menu is a very simple multi-level menu built from an HTML unorderd list, using Mootools Javascript Framework.

Download:MooTools Dropdown Menu (20.75 kB)

License:Free

Requirements:MooTools

How to use

Share/Save/Bookmark

  • No Related Post

 

Animated Menu Using jQuery

Category: Learn jQuery    |    670 views    |    Add a Comment  |   
Written by LXR   
Monday, 02 February 2009 05:40

Homepage:http://www.incg.nl/

Not work with IE6

Homepage:http://dragoninteractive.com/

 

Tutorials:http://www.shopdev.co.uk/blog/animated-menus-using-jquery/

Not work with IE6

 

 

Download: 3 Animated Menu Using jQuery (166.89 kB)

Share/Save/Bookmark

  • No Related Post

 

How to Create a Accordion in jQuery

Category: Learn jQuery    |    408 views    |    Add a Comment  |   
We are working with a simple <h3> / <div>structure:
  1. <div class=“demo-show2″>
  2.   <h3>Title 1</h3>
  3.   <div>Lorem…</div>
  4.   <h3>Title 2</h3>
  5.   <div>Ipsum…</div>
  6.   <h3>Title 3</h3>
  7.   <div>Dolor…</div>
  8. </div>
    JavaScript:
    1. $(document).ready(function() {
    2.   $(‘div.demo-show2> div’).hide();  
    3.   $(‘div.demo-show2> h3′).click(function() {
    4.     var $nextDiv = $(this).next();
    5.     var $visibleSiblings = $nextDiv.siblings(‘div:visible’);
    6.  
    7.     if ($visibleSiblings.length ) {
    8.       $visibleSiblings.slideUp(‘fast’, function() {
    9.         $nextDiv.slideToggle(‘fast’);
    10.       });
    11.     } else {
    12.        $nextDiv.slideToggle(‘fast’);
    13.     }
    14.   });
    15. });

Share/Save/Bookmark

  • No Related Post

 

How to write Better jQuery Code

Category: Learn jQuery    |    911 views    |    Add a Comment  |   

 

#1: Use data method instead of storing data inside the DOM.

The mistake I see people making all the time is this:

Copy Codeblock to Clipboard

JavaScript:
  1. $('selector').attr('alt', 'this is the data that I am storing');
  2. // then later getting that data with
  3. $('selector').attr('alt');

Why is this a bad thing?  Because “alt” has absolutely no meaning whatsoever, as well as HTML is not meant to store data.

Instead use the data method in jQuery. It allows you to associated data with an element on the page. 

Copy Codeblock to Clipboard

JavaScript:
  1. $('selector').data('meaningfullname', 'this is the data I am storing');
  2. // then later getting the data with
  3. $('selector').data('meaningfullname');

This allows you to store data with meaningful names and as much data as you want on any element on the page. It is a really amazing utility and something I’ve come to rely on. Read more…

Share/Save/Bookmark

  • No Related Post

 

jQuery FUNCTIONS

Category: Learn jQuery    |    609 views    |    1 Comment  |   

 

CALLBACKS AND FUNCTIONS

A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. The special thing about a callback is that functions that appear after the “parent” can execute before the callback executes.

Another important thing to know is how to properly pass the callback. This is where I have often forgotten the proper syntax.

Callback without arguments

For a callback with no arguments you pass it like this:

 $.get('myhtmlpage.html', myCallBack);

Note that the second parameter here is simply the function name (but not as a string and without parentheses). Functions in Javascript are ‘First class citizens’ and so can be passed around like variable references and executed at a later time.

Read more…

Share/Save/Bookmark

  • No Related Post

 

Adding and Removing a CSS Class with jQuery

Category: Learn jQuery    |    2,496 views    |    1 Comment  |   

irst, add some style information into the <head> of your document, like this:

 <style type="text/css">
    a.test { font-weight: bold; }
 </style>

Next, add the addClass call to your script:

  $("a").addClass("test");

All your a elements will now be bold.

To remove the class, use removeClass

 $("a").removeClass("test");
  • (CSS allows multiple classes to be added to an element.)
[edit]

Special Effects

In jQuery, a couple of handy effects are provided, to really make your web site stand out. To put this to the test, change the click that you added earlier to this:

 $("a").click(function(event){
   event.preventDefault();
   $(this).hide("slow");
 });

Now, if you click any link, it should make itself slowly disappear.

Share/Save/Bookmark

 

How jQuery Works

Category: Learn jQuery    |    1,033 views    |    Add a Comment  |   

 

THE BASICS

This is a basic tutorial, designed to help you get started using jQuery. If you don’t have a test page setup yet, start by creating a new HTML page with the following contents:

 

<html>

 

  <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
      // Your code goes here
    </script>
  </head>
  <body>
    <a href="http://jquery.com/">jQuery</a>
  </body>
  </html>

Edit the src attribute in the script tag to point to your copy of jquery.js. For example, if jquery.js is in the same directory as your HTML file, you can use:

 <script type="text/javascript" src="jquery.js"></script>

You can download your own copy of jQuery from the Downloading jQuery page.

Launching Code on Document Ready

 

The first thing that most Javascript programmers end up doing is adding some code to their program, similar to this: Read more…

Share/Save/Bookmark