Copy codeThe Code is as follows:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> usage of the jquery string cutting function substring </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Meta name = "Author" CONTENT = "Fanglor">
<Meta name = "Keywords" CONTENT = "jquery string cutting function substring usage">
<Meta name = "Description" CONTENT = "jquery string cutting function substring usage">
<Script type = "text/javascript" src = "jquery. js"> </script>
<Script language = "JavaScript">
<! --
Function sclip (){
If ($ ("# txt1"). val (). length> 6 ){
$ ("# Txt2"). val ($ ("# txt1"). val (). substring (0, 6 ));
} Else {
$ ("# Txt2"). val ($ ("# txt1"). val ());
}
}
// -->
</SCRIPT>
</HEAD>
<Input type = "text" id = "txt1"/>
<Input type = "text" id = "txt2"/>
<Input type = "button" onClick = "sclip ();" value = "do it..."/>
<BODY>
</BODY>
</HTML>