You'd have to test it. Could be either.
Karl Rudd On 4/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Thanks guys. Very helpful. So, which would be faster... $("fieldset input, fieldset select, fieldset textarea") or $("fieldset").find("intput,select,textarea") Thanks x 1,000,000 Karl Rudd wrote: You're on the right track. Yes you can join (or "chain") the "focus" and "blur" functions together. You also don't need to "return false" in the "focus" and "blur" functions, as that would/should "cancel" the event. You can also replace $(document).ready( function() {... with $( function() {... Here is what I would write (formatted how I usually like it): $( function() { $("fieldset input, fieldset select, fieldset textarea") .focus( function() { $(this.parentNode).addClass("on"); }) .blur( function() { $(this.parentNode).removeClass("on"); }); }); On 4/17/07, fambizzari <[EMAIL PROTECTED]> wrote: I am just beginning my journey with jQuery and would like to know how the following could be summarised: $(document).ready ( function() { $("fieldset input, fieldset select, fieldset textarea").focus ( function() { this.parentNode.className = "container on"; return false; } ); $("fieldset input, fieldset select, fieldset textarea").blur ( function() { this.parentNode.className = "container"; return false; } ); } ); This code is used on a form. When a form element is selected, it changes the classname of its parent (called "container") to "container on" (this class has some css attached to it). When the form element is de-selected, it changes the class name back to "container". Notes: 1) The code is split onto different lines to help me with visualisation because i am new to jQuery and am still getting used to it. 2) Is there are shorter version of saying $("fieldset input, fieldset select, fieldset textarea"). 3) Is it really necessary to repeat the two functions - one for focus and one for blur - or can they be joined? Thanks everyone. 1) The way it is spread out on different lines is to help me visualise what's going on. 2) The first area of summarisation i would