This article illustrates the method that JavaScript realizes the custom Hover,focus effect for input and textarea. Share to everyone for your reference. Specifically as follows:
Here demo JavaScript for input box and textarea text box custom Hover,
Effect Chart:
Specific implementation:
1, TEXTAREA label content
Copy Code code as follows:
2, initialization so that click the Add button, content display can enter up to 50 words
Copy Code code as follows:
document.getElementById ("Introduction"). Style.color= "Gray";
3. js Script
Copy Code code as follows:
var Textarea=document.getelementbyid
Colleagues in the production of touch screen when the product such a demand: " our page Why click the TextArea box, in the space, the iphone's keyboard can not hide?" "
We have tested this problem and it is not hidden. Look at other sites of the page, but also some can hide some can't hide.
Why didn't textarea lose focus when the iphone clicked on the documen
Due to the fact that compatibility is not considered, today we are experiencing this problem:HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>Documenttitle>Head>Body> textareaname=""ID=""cols= "+"rows= "Ten"readOnly=true>Sdfasdfadsfasdftextarea> Scriptsrc= "Jquery-1.9.1.js">Script> Scripttype= "Text/javascript"> $(function(){ $('textarea'). On ('Click',function(){
Today, we encountered this problem when submitting our form, so we can solve it with the legendary jquery.
Here we mainly talk about the focus issue in IE, because it is supported in Firefox
CopyCodeThe Code is as follows: input: Focus
Textarea: Focus
In ie: the focus is
JTextArea text=new JTextArea () Text.setlinewrap (TRUE);//Set the line wrap, then do not need to set the horizontal scroll bar jscrollpane scroll=new JScrollPane ( text);//Set horizontal and vertical scroll bars to appear automatically scroll.sethorizontalscrollbarpolicy (jscrollpane.horizontal_scrollbar_as_needed) respectively; Scroll.setverticalscrollbarpolicy (jscrollpane.vertical_scrollbar_as_needed); setting horizontal and vertical scrollbars, respectively, always appears Scroll.sethorizont
In particular Input[text] and textarea, and in the lower-right corner of the textarea also have a mouse to drag the table textarea size of the function, as shown in the following figure:
Input[text]:
TextArea
Sometimes the yellow border is very affecting the page effect, and
In particular, input [text] And textarea, and there is also a function of dragging the size of the table textarea in the lower right corner of textarea, as shown in:
Input [text]:
Textarea:
Sometimes the yellow border affects the page effect, and the layout is directly affected after the
Today, we encountered this problem when submitting our form, so we can solve it with the legendary jquery.Here we mainly talk about the focus issue in IE, because it is supported in firefoxCopy codeThe Code is as follows:Input: focusTextarea: focusIn IE: the focus is invalid. Therefore, we need to add a new style to the input and textarea after clicking to achiev
As we all know, the default Effect of textarea in WebKit browsers (Safari and chrome) is different from that in other browsers. For example, textarea can be dragged to adjust the size, and the border turns yellow when the focus is on. These effects are really cool, but sometimes we don't need them. What should we do? In fact, you can use CSS to easily cancel thes
The yellow border generated when the form item focus is canceled: input, button,Select, Textarea {outline: None} cancel the function of dragging and changing the size of textarea: textarea {resize: None}CancelTextarea's drop-down box (or scroll bar) under IE)Textarea {overfl
):
The code is as follows
Copy Code
7. Mouse to the text box, text box any text disappears (including the default text and later entered text):
The code is as follows
Copy Code
8. After clicking the text box, select the text in the full box:
The code is as follows
Copy Code
9. Move the mouse to the text box in the Full selection text box:
The code is as follows
. Container set the Overflow property, which causes the input box under the Android phone to get focus, the IME blocks the input box bug //Related issue:https://github.com/weui/weui/issues/ Solution: //0. Container Remove the overflow attribute, but this demo will cause other problems //1. Reference http://stackoverflow.com/questions/2375 7345/android-does-not-correctly-scroll-on-input-focus-if-
In the html element, textarea is a chicken rib. The obtained focus cursor cannot locate the last character. The author has a simple rich text box in the project, requiring users to enter characters and support emoticons at the same time. After an emoticon is selected, textarea obtains the focus, and the cursor stays at
Js implementation form (textarea) Acquisition and focus usage
In js, onfocus, onblur, onmouseover, and so on will be used. jquery binds events. The following uses textarea as an example. If input is used, the value is written differently.
1. display the default text in the text box:
The Code is as follows:
2. Click the tex
Encounter a feature that requires clicking on the title and inserting text into the existing text.The main code is as follows:var txtarea = $ ("#textArea") [0]; var content = txtarea.value; var // Initial position Txtarea.value = content.substring (0, Txtarea.selectionstart) + $ (this). Text () + content.substring ( Txtarea.selectionend, content.length); var position = start + $ (this). Text (). length;
7. Mouse to the text box, text box any text disappears (including the default text and later entered text):
The code is as follows
8. After clicking the text box, select the text in the full box:
The code is as follows
9. Move the mouse to the text box in the Full selection text box:
The code is as follows
10. Transfer from the current text box t
JavaScript allows Textarea to support the tab button
This example describes how to allow Textarea to support the tab button in JavaScript. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Summarize the focus management in Javascript in detail, and summarize the javascript focus
Focus Element
Which elements can get the focus? By default, only the form element can obtain the focu
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.