Javascript text box color changes when clicked
The default text box on the Web page is always gray, and it seems a little impatient. You all like to use CSS and JS to change its style. Today, I wrote a text box that changes the color of the clicked border, when you click the text box to be entered, the text box is automatically highlighted and highlighted, with visual effects, making the text box much more beautiful. The HTML code is as follows:
. Code
-
-
-
-
- The border color changes when the input box is clicked.
-
-
- <Script type = "text/javascript">
- // FocusClass: The style when the focus is obtained
- // NormalClass: normal style
- Function focusInput (focusClass, normalClass ){
- Var elements = document. getElementsByTagName ("input ");
- For (var I = 0; I <elements. length; I ++ ){
- If (elements [I]. type! = "Button" & elements [I]. type! = "Submit" & elements [I]. type! = "Reset "){
- Elements [I]. onfocus = function () {this. className = focusClass ;};
- Elements [I]. onblur = function () {this. className = normalClass | '';};
- }
- }
- }
- </Script>
- <Script type = "text/javascript">
- Window. onload = function (){
- FocusInput ('focusinput', 'normalinput ');
- }
- </Script>
- Enter the name:
-
-
-
It works in Firefox, but Firefox and chrome. By default, these two browsers will automatically input a box to add the click effect, so sometimes they cannot see clearly, and IE is outstanding. Front-end framework example