Chris, I think you would need to test for performance differences unless John or one of the other guys with more clue have some insight.
This works by creating a jquery collection of all td objects and using each to iterate through them, then uses the if to filter them. $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); Where as: $("[EMAIL PROTECTED]'enabled']").click() uses the xpath syntax to create a collection of just those td's that have the attribute state='enabled' set on them, then applies the click() method to each of them. The first is probably a little more readable if you are new to jquery and requires you to write more code. The later is probably more jQuery-ish and I guessing it is a little faster, but I have not done any testing and really have no facts to support the guess. -Steve Christopher Jordan wrote: > Thanks Klaus! > > How does this syntax differ from other suggested syntax: > > $("[EMAIL PROTECTED]'enabled']").click() > > I'm curiout which is preferred, or faster. They both look clean enough to me. > > Chris > > > > Klaus Hartl wrote: >> Christopher Jordan schrieb: >> >>> Hi folks, >>> >>> I have a table that represents a calendar. The user will be able to >>> select multiple dates from the calendar, but cannot select dates in the >>> past. I've written this code before using all JavaScript and what I did >>> was add several additional pieces of data to the td tag other than ID or >>> CLASS. I added "state", "index", "status" and a few others. I accessed >>> these through f.calendarid.state... that kind of thing. >>> >>> So I'm wanting to apply an event (probably several: click, mouseover, >>> mouseout) to only those td tags that have their state set to "enabled". >>> Not to *all* tds and not even to all tds with a certain class. ID alone >>> won't work. Is there a way to do this using jQuery? Something like: >>> $("td" status).click()... or whatever. >>> >>> Thanks, >>> Chris >>> >> >> Hi Christopher, this could work: >> >> $('td').each(function() { >> if (this.status == 'enabled') >> $(this).click(function() { >> // do something >> }); >> }); >> >> >> >> -- Klaus >> >> _______________________________________________ >> jQuery mailing list >> discuss@jquery.com <mailto:discuss@jquery.com> >> http://jquery.com/discuss/ >> >> >> >> > > ------------------------------------------------------------------------ > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/