If you're using id attributes correctly, there is only one occurrence
of any particular id in the document. So,

 $('.dateTable#'+dividedID+':first')
 $('.dateTable#'+dividedID+':first td#'+dayOfWeek)

is the same as

 $('#'+dividedID+':first').show();
 $(''#'+dayOfWeek)

If dayOfWeek is really just a number like '2' then it isn't a valid
id.

It's faster to use this.id directly rather than $(this).attr('id').

I suspect you could use text() instead of html() which is often faster
since the browser doesn't need to parse the incoming text as html.

With those things in mind, here's a moderately optimized version,
untested.

        $('.divideDate').livequery(function(){
                var splitDateTable = $('#'+this.id).text().split(' ');
                var dayOfWeek = splitDateTable[0];
                var numOfMonth = splitDateTable[1];
                $(''#'+this.id).show();
                $
('#'+dayOfWeek).text(numOfMonth).addClass('firstDate');
        });

livequery() has to do more work than if you do your own binding or re-
binding of events, so only use it when it's difficult to keep track of
things at document.load or the time of element creation.
Are .divideDate elements coming and going on the page? Or were you
just looking for a way to do an .each() to run that function on every
element once after the page loads?

How often is showDateDivides called? You should only need to call it
once if you are using livequery, since that will start monitoring for
new .divideDate elements that are created on the page.

Reply via email to