

Useful Jquery Examples - yottafala
http://techflame.posterous.com/useful-jquery-examples

======
simonw
This is just a selective repost of some of the tips from
[http://www.opensourcehunter.com/2010/02/27/26-cool-and-
usefu...](http://www.opensourcehunter.com/2010/02/27/26-cool-and-usefull-
jquery-tips-tricks-solutions/) \- and they're not particularly good tips
(using .html() to check if an element is empty seems pretty dodgy, for
example).

~~~
adriand
> they're not particularly good tips

I agree - not entirely sure how this climbed up so high on the front page.
There are far better resources available, including the jQuery documentation
itself, or [http://net.tutsplus.com/tutorials/javascript-
ajax/jquery-1-4...](http://net.tutsplus.com/tutorials/javascript-
ajax/jquery-1-4-released-the-15-new-features-you-must-know/)

------
rhythmAddict
I know I'm being a stickler here, but setTimeout() is conventional JS...

~~~
billybob
Yep. jQuery does have .delay() now, though. You can use it like this:

$('#thing').fadeIn(300).delay(2000).fadeOut(300);

~~~
SanjayU
Which is precisely the type of thing I'd think would be in the article :)

------
figital
Mike Susz's crazySquares is one of my favorite jQuery examples/tutorials:
<http://squaredesign.com/lab/crazy-squares/>

------
mshafrir
Personally, instead of

$('#id').replaceWith('<div>I have been replaced</div>');

I prefer

$('#id').replaceWith($('<div/>').text('I have been replaced.'));

------
Griever
As for empty elements, I believe you can always just use the :empty selector.

if($([selector]).is(":empty")) { // do stuff }

------
techiferous
I would recommend having jQuery Cookbook on your bookshelf. It's a great
resource.

[http://www.amazon.com/jQuery-Cookbook-Solutions-Examples-
Dev...](http://www.amazon.com/jQuery-Cookbook-Solutions-Examples-
Developers/dp/0596159773)

