Jquery focus () cannot get focus

Source: Internet
Author: User

One small problem today is that the text box can be submitted only after you enter the content. If you do not enter the content, a prompt will be prompted and the text box will get the focus! If jquery is not used, is it an object. focus () is enough, but when we use jquery, $ ("# nameinput") returns a jquery object instead of a DOM object, in this case, $ ("# nameinput "). the significance of the Focus () method has changed. Instead of getting the focus of this text box, it triggers all the functions bound to this text box in onfocus! In fact, using jquery is also very simple to convert jquery objects into a DOM object. I believe that developers have long considered this. It is really a worry for the world. $ ("# nameinput ") [0]. focus () simply adding a [0] is what we want !!

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.