News for hackers. Stuff that matters.
Re:Useful Jquery Examples by simonw on Monday April 19, 2010 @08:36AM (#1276555)
This is just a selective repost of some of the tips from http://www.opensourcehunter.com/2010/02/27/26-cool-and-usefu... - and they're not particularly good tips (using .html() to check if an element is empty seems pretty dodgy, for example).
Re:Useful Jquery Examples by adriand on Monday April 19, 2010 @11:13AM (#1276868)
> 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...

Re:Useful Jquery Examples by axod on Monday April 19, 2010 @10:01AM (#1276694)
What's wrong with using the DOM methods and properties as well? Not as sexy? :/

eg

  if(element.childNodes.length==0)
Re:Useful Jquery Examples by pistoriusp on Monday April 19, 2010 @11:28AM (#1276909)
I've flagged a bunch of posts like this over the last week?

I think someone is trying to game the system here.

Re:Useful Jquery Examples by rhythmAddict on Monday April 19, 2010 @09:23AM (#1276626)
I know I'm being a stickler here, but setTimeout() is conventional JS...
Re:Useful Jquery Examples by billybob on Monday April 19, 2010 @10:19AM (#1276738)
Yep. jQuery does have .delay() now, though. You can use it like this:

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

Re:Useful Jquery Examples by SanjayU on Monday April 19, 2010 @11:42AM (#1276941)
Which is precisely the type of thing I'd think would be in the article :)
Re:Useful Jquery Examples by figital on Monday April 19, 2010 @11:46AM (#1276958)
Mike Susz's crazySquares is one of my favorite jQuery examples/tutorials: http://squaredesign.com/lab/crazy-squares/
Re:Useful Jquery Examples by mshafrir on Monday April 19, 2010 @09:06AM (#1276592)
Personally, instead of

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

I prefer

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

Re:Useful Jquery Examples by Griever on Monday April 19, 2010 @11:22AM (#1276890)
As for empty elements, I believe you can always just use the :empty selector.

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

Re:Useful Jquery Examples by techiferous on Monday April 19, 2010 @11:28AM (#1276908)
I would recommend having jQuery Cookbook on your bookshelf. It's a great resource.

http://www.amazon.com/jQuery-Cookbook-Solutions-Examples-Dev...