$(document).ready shorthand

Is the following shorthand for $(document).ready? (function($){ //some code })(jQuery); I see this pattern used a lot, but I’m unable to find any reference to it. If it is shorthand for $(document).ready(), is there any particular reason it might not work? In my tests it seems to always fire before the ready event. 8 Answers … Read more

Omitting the second expression when using the if-else shorthand

Can I write the if else shorthand without the else? var x=1; x==2 ? dosomething() : doNothingButContinueCode(); I’ve noticed putting null for the else works (but I have no idea why or if that’s a good idea). Edit: Some of you seem bemused why I’d bother trying this. Rest assured it’s purely out of curiosity. … Read more

CSS transition shorthand with multiple properties?

I can’t seem to find the correct syntax for the CSS transition shorthand with multiple properties. This doesn’t do anything: .element { -webkit-transition: height .5s, opacity .5s .5s; -moz-transition: height .5s, opacity .5s .5s; -ms-transition: height .5s, opacity .5s .5s; transition: height .5s, opacity .5s .5s; height: 0; opacity: 0; overflow: 0; } .element.show { … Read more