When jQuery1.7 encounters a problem with the focus Method _ jquery-js tutorial

Source: Internet
Author: User
If you must use the highest version of jQuery, the most convenient way is to write xxx. add a trycatch to focus () and change it to try {xxx. focus ();} catch (e) {} There is a focus () method in jQuery that can set the focus of an object. In versions earlier than 1.7, whether the object is in the disabed state or not, this method will not report an error (only when the focus is set to disabled, the code that sets the focus is invalid), but in version 1.7, if the object is in the disabled status, when the focus () method is called, an exception is reported directly:

Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.

Meaning:Invisible or unavailable elements cannot obtain the focus. (In particular, IE9 is very NB and can automatically identify this situation. In IE9, no error is reported, but IE9 or earlier versions are all suspended .)

The Code is as follows:





Test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.