If you must use the highest version of jquery, the easiest way to do this is to add a try/catch to Try{xxx.focus () when writing xxx.focus (); catch (e) {}
In jquery, there is a focus () method that sets the focal point of the object. In versions below 1.7, this method does not report an error, regardless of whether the object is a disabed state (only if the code that sets the focus is not valid when disabled), but in version 1.7, if the object is a disabled state, then it is reported directly when the focusing () method is invoked: Error:can ' t move focus-control because it are invisible, not enabled, or of a type that does not accept the Focus. means that an element that is not visible or unavailable does not get focus. (Special mention: IE9 is very NB, can automatically recognize this situation, in the IE9 will not be an error, but IE9 the following version of all hang. ) Code as follows: <!doctype html> <html> <head> <title> test </title> <script src= "Jquery-1.7.min.js" type= "Text/javascript" ></script> <!--<script src= " Jquery-1.4.4.min.js "type=" Text/javascript "></script>--> <script type=" Text/javascript "> function Fntest () { //try{ $ ("#txt"). focus (); //}catch (e) {} } </script> </head> <body> <div> <input type= "text" disabled= "Disabled" id= "txt"/> <input type= "text" id= "Txt2"/> <input type= "button" value= "Test" onclick= "fntest ()"/> </div> </body> < /html> Although only a small change, but it is easy to create large cups, especially your JS code, after focus (), there are many other things to do:) advice: If you must use the highest version of jquery, The easiest way to do this is to add a try/catch to the Try{xxx.focus () when writing xxx.focus (); catch (e) {}