Home Web Front-end JS Tutorial JavaScript聚焦于第一个字段的代码_表单特效

JavaScript聚焦于第一个字段的代码_表单特效

May 16, 2016 pm 06:18 PM
Field focus

这个主要会用在表单字段中,所以我这里做的实验只针对表单字段。在form的子元素中循环查找第一个不是隐藏字段的字段,然后使用focus方法获得焦点。(呵呵^_^,很简单!)

复制代码 代码如下:

FormUtil.focusOnFirst = function() {
if (document.forms.length > 0) {
for (var i = 0; i var oField = document.forms[0].elements[i];
if (oField.type != "hidden") {
oField.focus();
return;
}
}
}
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to Download Windows Spotlight Wallpaper Image on PC How to Download Windows Spotlight Wallpaper Image on PC Aug 23, 2023 pm 02:06 PM

Windows are never one to neglect aesthetics. From the bucolic green fields of XP to the blue swirling design of Windows 11, default desktop wallpapers have been a source of user delight for years. With Windows Spotlight, you now have direct access to beautiful, awe-inspiring images for your lock screen and desktop wallpaper every day. Unfortunately, these images don't hang out. If you have fallen in love with one of the Windows spotlight images, then you will want to know how to download them so that you can keep them as your background for a while. Here's everything you need to know. What is WindowsSpotlight? Window Spotlight is an automatic wallpaper updater available from Personalization &gt in the Settings app

Beautiful pictures change every day! A complete guide to focusing on desktop and lock screen settings in Windows 11 Beautiful pictures change every day! A complete guide to focusing on desktop and lock screen settings in Windows 11 Mar 25, 2024 am 09:01 AM

Windows 11’s Focus feature can automatically update your desktop wallpapers, themes, and lock screen interface, presenting you with a selection of beautiful pictures of landscapes, cities, animals, etc. every day. These images are all sourced from Bing search, which not only makes the user experience more personalized, but also occasionally displays practical suggestions and tips on the lock screen, bringing additional surprises and help to users. Method 1 to use Windows 11 Focus Desktop: Set Windows Focus Desktop Wallpaper 1 Press the Windows+I shortcut key to open "Settings" and select "Personalization" > "Background". 2 In the "Personalize background" drop-down list, select the "Windows Focus" option. Select Windows Spotlight Wallpaper

How to determine if a field is empty in PHP? How to determine if a field is empty in PHP? Mar 20, 2024 pm 03:09 PM

PHP is a scripting language widely used in website development. For developers, it is often necessary to determine whether a field is empty. In PHP, determining whether a field is empty can be achieved through some simple methods. This article will introduce how to determine whether a field is empty in PHP, and provide specific code examples for your reference. In PHP, you can usually use the empty() function or isset() function to determine whether a field is empty. Next, we introduce the usage of these two functions respectively. Use the empty() function

NoSuchFieldError in Java - Solution to field not found NoSuchFieldError in Java - Solution to field not found Jun 25, 2023 am 11:33 AM

NoSuchFieldError in Java - Solution to field not found Java is a high-level programming language that is widely used in enterprise-level applications and large-scale data processing. During the development process of Java, errors such as NoSuchFieldError may occur. This error means that the JVM cannot find the required field at runtime. In this article, we will take a deeper look at NoSuchFieldError and how to resolve it. What is NoSuchFieldE

What does windows focus mean? What does windows focus mean? Feb 01, 2024 pm 09:27 PM

Windows Focus is a personalized lock screen theme setting function that allows you to freely change the background image in the lock screen view and provides users with relevant suggestions based on the settings. This feature is widely applicable to Windows 10 environments including all desktop versions. How to use windows focus function This feature introduced in Windows 10 is designed to allow users to no longer just enjoy static wallpapers, but to experience diverse and dynamic background screen changes during computer lockout. Background images are usually automatically downloaded and changed based on user preferences and habits. In addition, there are also situations where WindowsFocus will present multiple different background images on the frequency lock interface at the same time, and even give practical suggestions or information in specific scenarios. Note: in w

What does mysql field mean? What does mysql field mean? Jul 10, 2023 pm 02:14 PM

A mysql field is a column of a specific type and length in a mysql database table that is used to store data. In MySQL, each field must have a specific data type. Common data types include integers, floating point numbers, strings, dates, and times. These data types determine the data that MySQL can store in each field.

How to add fields to the database table How to add fields to the database table Mar 18, 2021 pm 02:13 PM

Methods to add fields in the table: 1. Use the "ALTER TABLE table name ADD new field name data type;" statement to add fields at the end; 2. Use the "ALTER TABLE table name ADD new field name data type FIRST;" statement to add it at the beginning Field; 3. Use the "ALTER TABLE table name ADD new field name data type [constraints] AFTER existing field name;" statement to add a field in the middle.

How to add fields in dedecms How to add fields in dedecms Feb 17, 2023 am 10:50 AM

How to add fields to dedecms: 1. Enter the dedecms backend and find the "Common Article Model" in "Core-Channel Model"; 2. Click "Field Management" to enter the field management interface and click Add New Field; 3. Add a new field In the field interface, just fill in the form prompt text, field name and other information in sequence.

See all articles