To work on any type of input should be easy, just replace ':text' with input.
I know that IE would give error when you're focusing a 'disappearing' input. (parent is hidden, for example). But I do not encounter any error like you described. Any sample code for your HTML? On Tue, Apr 15, 2008 at 9:00 AM, MichaelEvangelista <[EMAIL PROTECTED]> wrote: > > I've been looking for a solution like this, but that will work with > any type of form input. > The code I've been using is below (where form-id is the ID of the > containing form) > > It works great in Firefox but IE throws the error > 'this.parentNode.borderCss.on' is null or not an object > > I tried your example code above, and got the same error > > here is what I was using : > > // ------- Put the cursor in the first field on page load > var $firstfield = function(){ > $('#form-id input:eq(0)').focus(); > } > $firstfield(); > > Could this have anything to do with my markup? I didnt get that error > on your demo, but i did when I applied your code to my form. > > > > On Apr 13, 7:54 am, Jacky See <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > For focusing first input text field, the usual solution is $ > > (':text:visible:enabled:eq(0)').focus(). However, when these fields > > are in an ':hidden' parent (not 'visible' by our eyes), it won't work. > > > > Currently I tried to solve this by: > > > > $(":text:visible:enabled").filter(function(){ > > return $(this).parents(":hidden").size()==0; > > > > }).slice(0,1).focus(); > > > > I have setup a test page for this: > http://www.seezone.net/dev/focusField.html > > Try to toggle different parent to and click 'focus'. It should work > > correctly. > > > > I would like to know if there is any other 'selector-based' way to do > > so? > -- Best Regards, Jacky 網絡暴民 http://jacky.seezone.net