Home Web Front-end JS Tutorial JavaScript (js) sets the default input focus (focus)_javascript skills

JavaScript (js) sets the default input focus (focus)_javascript skills

May 16, 2016 pm 05:45 PM
focus focus enter

This function is often used in replies and quotes, that is, click the reply or quote. For example, if the input focus appears in the message input box, if anchors are used to position it, the input focus cannot be activated.

Copy code The code is as follows:

javascript:document.getElementById("id").focus ();
or javascript:document.all.id.focus();
or javascript:document.all.name.focus();

Example:
Copy code The code is as follows:




Let’s take a closer look at the positioning of replies and quotes used in this blog, and how to position the focus on the right side of the text.
Copy code The code is as follows:

//Quote calling function
function quote(name ,id){
var quoteMsg=document.getElementById(id).innerHTML;
var content=document.getElementById("comment");
quoteMsg=quoteMsg.replace(//g, "~^").replace(/
/ g,'n');
content.focus();//To have the focus on the right side of the text, this line of code must be in front
content.value=quoteMsg '[Quote' name ']' 'n ' '——————————————————————' 'n'; //Fill in the text afterwards
return false; //Cancel the function of href
}
//Reply the automatic name input function
function backcomment(msg){
backdb=document.getElementById('comment');
backdb.focus();
backdb.value= msg 'n';
return false;
//return true; Originally used anchor to position
}
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Disabling Win11 Input Experience Guide Disabling Win11 Input Experience Guide Dec 27, 2023 am 11:07 AM

Recently, many Win11 users have encountered the problem that the input experience dialog box always flickers and cannot be turned off. This is actually caused by the default system services and components of Win11. We need to disable the relevant services first, and then disable the input experience service. Solved, let’s try it out together. How to turn off the input experience in win11: First step, right-click the start menu and open "Task Manager". Second step, find the three processes "CTF Loader", "MicrosoftIME" and "Service Host: Textinput Management Service" in order, right-click "End Task" "The third step, open the start menu, search and open "Services" at the top. The fourth step, find "Textinp" in it

Windows input encounters hang or high memory usage [Fix] Windows input encounters hang or high memory usage [Fix] Feb 19, 2024 pm 10:48 PM

The Windows input experience is a key system service responsible for processing user input from various human interface devices. It starts automatically at system startup and runs in the background. However, sometimes this service may automatically hang or occupy too much memory, resulting in reduced system performance. Therefore, it is crucial to monitor and manage this process in a timely manner to ensure system efficiency and stability. In this article, we will share how to fix issues where the Windows input experience hangs or causes high memory usage. The Windows Input Experience Service does not have a user interface, but it is closely related to handling basic system tasks and functions related to input devices. Its role is to help the Windows system understand every input entered by the user.

C/C++ program to find the vertex, focus and directrix of a parabola C/C++ program to find the vertex, focus and directrix of a parabola Sep 05, 2023 pm 05:21 PM

Asetofpointsonaplainsurfacethatformsacurvesuchthatanypointonthatcurveisequidistantfromapointinthecenter(calledfocus)isaparabola.Thegeneralequationfortheparabolaisy=ax2+bx+cThevertexofaparabolaisthecoordinatefromwhichittakesthesharpestturnwhereasaisth

How to remove focus in jquery How to remove focus in jquery Feb 17, 2023 am 10:20 AM

How to remove focus in jquery: 1. Get the focus through "document.getElementById('test').focus()"; 2. Use the "document.getElementById('test').blur();" method to remove the focus .

Solve win11 search bar input problem Solve win11 search bar input problem Dec 26, 2023 pm 12:07 PM

The search bar is a very useful function in the win11 system, which can help us find the settings, functions and services we want. However, some friends have encountered the situation where the win11 search bar cannot be entered. We can modify the relevant data in the registry to solve the problem. Let's follow the editor to solve it. What to do if you can’t type in the win11 search bar 1. First, we can press “win+r” on the keyboard to bring up run. 2. Then enter "regedit" and press Enter to open the Registry Editor. 3. Then enter "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Expl" in the path above

Comparison of focus and blur methods in jQuery Comparison of focus and blur methods in jQuery Feb 23, 2024 pm 03:51 PM

Comparison of focus and blur methods in jQuery In JavaScript, focus and blur are two commonly used events, used to handle the situation when an element gains focus and loses focus. In jQuery, there are also corresponding methods for handling the focus and blur events of elements. This article will compare the usage of focus and blur methods in jQuery, and illustrate their differences and application scenarios through specific code examples. focus method focus method is used for

How to input word matrix How to input word matrix Mar 19, 2024 pm 11:00 PM

Matrix is ​​a formula we often use and encounter, but do you know how to input a matrix in word? Many people may have never been exposed to it and will feel confused when using it. So, here we will share with you how to input the word matrix. I hope that sharing this technique can bring help and inspiration to you. 1. First, create and open a word document. In order to demonstrate the operation, we will use a blank document for demonstration. As shown in the figure below: 2. If we want to input the matrix, we need to find the [Insert] button in the menu bar. This button can insert many content options, such as pictures, etc., all from this menu bar. 3. After clicking [Insert], look on the right side of our tool options and you can find [Formula], and then we click [

C program to input an array of sequences of integers separated by spaces C program to input an array of sequences of integers separated by spaces Aug 25, 2023 am 11:33 AM

Problem Statement Write a C program that takes space separated integers as array input. SampleExamples input 12345 output ‘Arrayelementsare-’1,2,3,4,5Explanation’s Chinese translation is: The explanation input contains 5 integers separated by spaces. Input 997687542356878967343423 Output ‘Arrayelementsare-’99,76,87,54,23,56,878,967,34,34,23 The Chinese translation of Explanation is: Explanation The input contains 11 integers separated by spaces. Method 1 In this method, we will replace the input with empty

See all articles