jquery gets the various ways in which the values in input type= "text"

Source: Internet
Author: User

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml><HTMLxmlns= "http://www.w3.org/1999/xhtml">    <Head>        <title>jquery Gets the value of a text box</title>        <Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312" />        <Scriptsrc= "Jquery-1.5.1.min.js"type= "Text/javascript"></Script>                <Scripttype= "Text/javascript">        //use ID to get$ (document). Ready (function(){            //1            $("#button_text1"). Click (function(){                varRESULT1= $("#input_text1"). Val (); Alert ("RESULT1 =" +RESULT1);            }); //2            $("#button_text2"). Click (function(){                varresult2= $("input[id= ' input_text2 ']"). Val (); Alert ("result2 =" +result2);            }); //3            $("#button_text3"). Click (function(){                varRESULT3= $("input[id= ' input_text3 ']"). attr ("value"); Alert ("RESULT3 =" +RESULT3);            }); //4. The value in input can be obtained by the value of type (not shown)            /*$ ("#button_text4"). Click (function () {var result4 = $ ("input[type= ' text ']"). Val ();            Alert ("RESULT4 =" + RESULT4);            }); */            //5. The value in input can be obtained by the value of name (not shown)            /*$ ("#button_text5"). Click (function () {var result5 = $ ("input[name= ' text ']"). Val ();            Alert ("RESULT5 =" + RESULT5);                        }); */        }); </Script>    </Head>    <Body>        <!--gets the value of the text box: Way One -        <DivID= "Test1">            <inputID= "Input_text1"type= "text"value= "Test1"style= "width:100px;" />            <ButtonID= "Button_text1">Test1</Button>        </Div>        <!--get the value of the text box: mode two -        <DivID= "Test2">            <inputID= "Input_text2"type= "text"value= "Test2"style= "width:100px;" />            <ButtonID= "Button_text2">Test2</Button>        </Div>        <!--gets the value of the text box: Way three -        <DivID= "Test3">            <inputID= "Input_text3"type= "text"value= "Test3"style= "width:100px;" />            <ButtonID= "Button_text3">Test3</Button>        </Div>    </Body></HTML>

jquery gets the various ways in which the values in input type= "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.