Wow...excellent suggestions...I did not know that you could/should do that much chaining...though admittedly as a newbie to jQuery, having the separated initially helps me debug quite a bit. But thank you very much for the tip...once I solve my problem in IE, I will definitely do this.
On Jul 27, 2:11 am, Stephan Beal <[EMAIL PROTECTED]> wrote: > Hi, Mike! > > Something not directly related to your problem, but maybe helpful > nonetheless... > > you can chain a lot of these calls to make them run faster. As it is > written now, you are forcing jQ to repeat a few of the searches > several times... > > On Jul 27, 1:54 am, mcraig <[EMAIL PROTECTED]> wrote: > > > $("#switchkey p").corner("bottom 6px;"); > ... > > $("#switchkey p").click(function() { > > $("#switchcontent").animate({height: 'toggle', > > opacity: 'toggle'}, > > 500, function() { > > Can be: > > $("#switchkey p").corner("bottom 6px;") > .$("#switchkey p").click(function() {... > > > $("#switchkey p").html('Close Site Panel'); > > $("#switchkey p").corner("bottom 6px;"); > > $("#switchkey p").html('Site Panel'); > > $("#switchkey p").corner("bottom 6px;"); > > Those can/should all be chained together: > > $("#switchkey p").html('Close Site Panel') > .corner("bottom 6px;") > .html('Site Panel') > .corner("bottom 6px;"); > > Doing so should speed up that portion of code more than 50%. > > > $("#logincontent").animate({height: 'toggle', > > opacity: 'toggle'}, > > 500, function() { > > > > if ($("#logincontent").is(':visible')) { > > Inside the anonymous function 'this' refers to #logincontent, so you > should use this instead of $('#logincontent'), to avoid doing yet > another search for an item you already have. > > $("#loginkey p").html('Close Login'); > > > > > $("#loginkey p").corner("bottom 6px;"); > > You can chain these. > > $("#loginkey p").html('Login'); > > > > > $("#loginkey p").corner("bottom 6px;"); > > And these, too. > > Chaining does not only exist to make code prettier, but to save a lot > of internal work. Every time you do $('#foo'), the whole DOM has to be > searched to find the element, which takes so-called "linear > time" (meaning that the time it takes grows in direct proportion to > the length of your DOM), whereas if you chain calls you perform the > search only once and re-use the found element. The speed savings are > in direct relation to how many calls you can effectively chain. e.g. > if you can chain 3 calls then you've effectively cut the search time > to 1/3rd of what it would be when not chaining the calls. Failing to > use chaining (or caching a $(...) result) inside of a loop can be a > big performance hit. > > Good luck solving your IE problem! i'm so glad i don't own Windows, so > i don't have to put up with that browser! :D