The most famous example is assigning attribute values to the new military commanders in the Three Kingdoms and the taige.
The following section uses javascript to hide the link underline on the page.
Let's take a look at some better optimization suggestions.
The following code is used:
Test.html:
Copy codeThe Code is as follows:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
<Script language = "JavaScript" src = "util. js" type = "text/JavaScript"> </script>
<Link rel = "stylesheet" href = "link.css" type = "text/css">
</HEAD>
<BODY>
<Form name = "Register1Form" method = "POST">
<Table>
<Tr>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "font1"> <div align = "right"> username </div> </ td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "font1"> <div align = "center">
<Input name = "username" type = "text" size = "10" maxlength = "10" value = "1">
</Div> </td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "bg2">
<Div align = "center"> <font color = "# FF0000"> <font color = "# FF0000"> <font face = ""> <a href = "" onclick = "javascript: add (Register1Form); return false; "class =" A "> + </a> </font> </div & gt; </td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "bg2">
<Div align = "center"> <font color = "# FF0000"> <font color = "# FF0000"> <font face = ""> <a href = "" onclick = "javascript: subtration (Register1Form); return false; "class =" A ">-</a> </font> </div & gt; </td>
</Tr>
<Tr>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "font1"> <div align = "right"> meili </div> </ td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "font1"> <div align = "center">
<Input name = "meili" type = "text" size = "10" maxlength = "10" value = "1">
</Div> </td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "bg2">
<Div align = "center"> <font color = "# FF0000"> <font color = "# FF0000"> <font face = ""> <a href = "" onclick = "javascript: add2 (Register1Form); return false; "class =" A "> + </a> </font> </div & gt; </td>
<Td height = "30" bordercolor = "# FFFFFF" bgcolor = "# D0E8FF" class = "bg2">
<Div align = "center"> <font color = "# FF0000"> <font color = "# FF0000"> <font face = ""> <a href = "" onclick = "javascript: subtration2 (Register1Form); return false; "class =" A ">-</a> </font> </div & gt; </td>
</Tr>
</Table>
</Form>
</Body>
</Html>
Link.css:
Copy codeThe Code is as follows:
. {
Text-transform: none;
Text-decoration: none;
}
. A: hover {
Text-decoration: underline
}
The final part is util. js (this code is too long ):
Copy codeThe Code is as follows:
Var flag = false;
Function add (formname ){
If (formname. username. value = ""){
Alert ("enter a positive integer ");
Formname. username. focus ();
Return false;
}
Flag = checkscope (formname );
If (flag = false ){
Return false;
}
If (parseInt (formname. username. value)> 0 ){
Formname. username. value = parseInt (formname. username. value) + 1;
If (parseInt (formname. username. value) + parseInt (formname. meili. value)> 10 ){
Alert ("the sum of the input integers cannot be greater than 10 ");
Formname. username. value = 10-parseInt (formname. meili. value );
Return false;
} Else
Return true;
} Else {
Alert ("the input integer must be greater than 0 ");
Formname. username. value = 1;
Return false;
}
}
Function subtration (formname ){
If (formname. username. value = ""){
Alert ("enter a positive integer ");
Formname. username. focus ();
Return false;
}
Flag = checkscope (formname );
If (flag = false ){
Return false;
}
If (parseInt (formname. username. value)> 1 ){
Formname. username. value = parseInt (formname. username. value)-1;
If (parseInt (formname. username. value) + parseInt (formname. meili. value)> 10 ){
Alert ("the sum of the input integers cannot be greater than 10 ");
Formname. username. value = 10-parseInt (formname. meili. value );
Return false;
} Else
Return true;
} Else if (parseInt (formname. username. value) = 1 ){
Alert ("it is already the minimum value and cannot be reduced ");
Return false;
} Else {
Alert ("the input integer must be greater than 1 ");
Formname. username. value = 1;
Return false;
}
}
Function add2 (formname ){
If (formname. meili. value = ""){
Alert ("enter a positive integer ");
Formname. meili. focus ();
Return false;
}
Flag = checkscope (formname );
If (flag = false ){
Return false;
}
If (parseInt (formname. meili. value)> 0 ){
Formname. meili. value = parseInt (formname. meili. value) + 1;
If (parseInt (formname. username. value) + parseInt (formname. meili. value)> 10 ){
Alert ("the sum of the input integers cannot be greater than 10 ");
Formname. meili. value = 10-parseInt (formname. username. value );
Return false;
} Else
Return true;
} Else {
Alert ("the input integer must be greater than 0 ");
Formname. meili. value = 1;
Return false;
}
}
Function subtration2 (formname ){
If (formname. meili. value = ""){
Alert ("enter a positive integer ");
Formname. meili. focus ();
Return false;
}
Flag = checkscope (formname );
If (flag = false ){
Return false;
}
If (parseInt (formname. meili. value)> 1 ){
Formname. meili. value = parseInt (formname. meili. value)-1;
If (parseInt (formname. username. value) + parseInt (formname. meili. value)> 10 ){
Alert ("the sum of the input integers cannot be greater than 10 ");
Formname. meili. value = 10-parseInt (formname. username. value );
Return false;
} Else
Return true;
} Else if (parseInt (formname. meili. value) = 1 ){
Alert ("it is already the minimum value and cannot be reduced ");
Return false;
} Else {
Alert ("the input integer must be greater than 1 ");
Formname. meili. value = 1;
Return false;
}
}
Function checkscope (formname ){
If (parseInt (formname. username. value)> 9) | (parseInt (formname. username. value) <1 )){
Alert ("username input number exceeds the permitted range of 1-9 ");
Formname. username. value = 1;
Formname. username. focus ();
Return false;
}
If (parseInt (formname. meili. value)> 9) | (parseInt (formname. meili. value) <1 )){
Alert ("meili input number exceeds the permitted range of 1-9 ");
Formname. meili. value = 1;
Formname. meili. focus ();
Return false;
}
Return true;
}
Put the three files in the same folder and try the effect. I certainly didn't lie to you.