In the previous essay, Xiao Ying shared the Text-transform property control text with the CSS, the case of small ying to share a section with jquery to control the size of the text, because Xiao Ying has not written jquery for a long time, if there is anything wrong place want everyone to tell Xiao Ying Oh , Xiao Ying to correct, good nonsense not much to say, below everyone please look at Xiao Ying code: ~~~~~ when when
HTML code:
<!DOCTYPE HTML><HTML> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <Scripttype= "Text/javascript"src= "/jquery/css/js/jquery-2.1.3.min.js"></Script> <title>CSS Text-transform</title> <Scripttype= "Text/javascript">JQuery (function(){ $(". First-big-letter"). KeyUp (function(){ if($( This). val (). Length>0) {Let Firbigl=$( This). Val (); Let Headerarry=[]; for(varI=0; I<Firbigl.length;i++) {Headerarry[i]=firbigl.substring (i, (i+1)); } Firbigl="'; headerarry[0]=headerarry[0].touppercase (); for(varI=0; I<Headerarry.length;i++) {Firbigl+=Headerarry[i]; } console.log (Firbigl); $( This). Val (Firbigl); Console.log ($ ( This). Val ()); } }); $(". Big-letter"). KeyUp (function(){ if($( This). val (). Length>0) {Let Secbigl=$( This). Val (); Secbigl=secbigl.touppercase (); $( This). Val (Secbigl); } }); $(". Small-letter"). KeyUp (function(){ if($( This). val (). Length>0) {Let Thirdbigl=$( This). Val (); Thirdbigl=thirdbigl.tolowercase (); Console.log (THIRDBIGL); $( This). Val (Thirdbigl); } }); }); </Script> </Head> <Body> <Divclass= "header"> <Divclass= "Header-big-letter"> <label>Capitalize first letter:</label> <inputtype= "text"class= "First-big-letter"> </Div> <Divclass= "All-big-letter"> <label>Only uppercase letters can be entered:</label> <inputtype= "text"class= "Big-letter"> </Div> <Divclass= "All-small-letter"> <label>You can only enter lowercase letters:</label> <inputtype= "text"class= "Small-letter"> </Div> </Div> </Body></HTML>
Css:
<style>.header{width:400px;Height:400px;Margin-left:400px;Background-color:Pink}. Header-big-letter{Padding-top:50px;Padding-bottom:20px;}/*. first-big-letter{text-transform:capitalize;}*/. All-big-letter{Padding-bottom:20px;}/*. big-letter{text-transform:uppercase;}*/. All-small-letter{Padding-bottom:20px;}/*. small-letter{text-transform:lowercase;}*/</style>
Let's look at the effect:
jquery controls the case of text.