views:

85

answers:

1

Hello, I'm trying to set the focus to an element in a hidden div, after I call the Show method. Here is the code:

//Show the Bottom Div
$('#dvBottom').show('medium', function()
{
    switch (hdnGenerateScaffoldCount.value.toUpperCase())
    {
       case "Y":
          $('#dvManualDocumentID').show('fast', function()
          {
             $('#txtScaffoldCountSheetNumber input').focus();
          });
       break;
       default:
          $('#txtJobs input').focus();
       break;
    }
});

the two divs display properly, but focus is always on the Address bar of the browser. I've tried this in IE8 Strict and FF and the same behavior happens in both.

I've stepped through the code and the following is executed:

$('#txtScaffoldCountSheetNumber input').focus();

I've even set the value to "Hello World" on Focus, and the text appears, but the focus is always lost. I have nothing else going on in this script and I appreciate any help

Terry P.S. The HTML Renders fine. Both Div's are visible by default and hidden on page load in jquery.

A: 

Divs can't receive focus without @tabindex set, try:

<div tabindex="-1"></div>
Thomas J Bradley
Thanks Thomas, I'll give it a try.
TGS