Useful Jquery Examples(techflame.posterous.com)
techflame.posterous.com
Useful Jquery Examples
http://techflame.posterous.com/useful-jquery-examples
6 comments
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).
> 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...
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...
What's wrong with using the DOM methods and properties as well? Not as sexy? :/
eg
eg
if(element.childNodes.length==0)I've flagged a bunch of posts like this over the last week?
I think someone is trying to game the system here.
I think someone is trying to game the system here.
I know I'm being a stickler here, but setTimeout() is conventional JS...
Mike Susz's crazySquares is one of my favorite jQuery examples/tutorials: http://squaredesign.com/lab/crazy-squares/
Personally, instead of
$('#id').replaceWith('<div>I have been replaced</div>');
I prefer
$('#id').replaceWith($('<div/>').text('I have been replaced.'));
$('#id').replaceWith('<div>I have been replaced</div>');
I prefer
$('#id').replaceWith($('<div/>').text('I have been replaced.'));
As for empty elements, I believe you can always just use the :empty selector.
if($([selector]).is(":empty")) { // do stuff }
if($([selector]).is(":empty")) { // do stuff }
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-Dev...