(tricks and tips) 4 Jquery awesome features

As everyone knows,Jquery is a awesome javascript framework,here i will show you some awesome features i find in jquery.

1.Before intruducing this feature,everyone think about your “a” link in html,do you use “target=’_blank’” in your website? And do you know it is not allowed in XHTML 1.0 Strict,here is solution to it.

$('a[@rel$='external']').click(function(){
this.target = "_blank";
});

/*
Usage:
lepinskidesign.com.br
*/

2.This tips is not very covert,many may had use it.To get the total num of one element,you can use:

$('element').size();

3.When your page include many images,the best way to show it ,you can preload your images.As it means,your image will be loaded before you show it the right time.

jQuery.preloadImages = function()
{
  for(var i = 0; i").attr("src", arguments[i]);
  }
};

// Usage
$.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");

4.Many times you shoule detect browsers for your project,with jquery you can do it easily.Also you can do it in css,here is the jquery way.

//A. Target Safari
if( $.browser.safari ) $("#menu li a").css("padding", "1em 1.2em" );

//B. Target anything above IE6
if ($.browser.msie && $.browser.version > 6 ) $("#menu li a").css("padding", "1em 1.8em" );

//C. Target IE6 and below
if ($.browser.msie && $.browser.version <= 6 ) $("#menu li a").css("padding", "1em 1.8em" );

//D. Target Firefox 2 and above
if ($.browser.mozilla && $.browser.version >= "1.8" ) $("#menu li a").css("padding", "1em 1.8em" );

Some of these tips ,i had found it before,and some are found from featured jquery aritlces,wished you will learn it!

One thought on “(tricks and tips) 4 Jquery awesome features

  1. I do trust all of the ideas you’ve offered on your post. They’re really convincing and will certainly work. Still, the posts are very quick for newbies. Could you please lengthen them a little from next time? Thank you for the post.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>