jquery controls the case of text.

Source: Internet
Author: User

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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.