jquery settings and get a simple example of HTML, text, and values

Source: Internet
Author: User
Tags cdata empty

  This article is mainly about the jquery settings and access to HTML, text and values of simple examples are introduced, the need for friends can come to the reference, I hope to help you.

  Code as follows: <script type= "Text/javascript" >  //<! [cdata[  $ (function () {     //Get the <p> element's HTML code       $ ("Input:eq (0)"). Click ( function () {            alert ( $ ("P"). html ());      });      //Get <p> element text       $ ("Input:eq (1)"). Click (function () {      &NBS P     Alert ( $ ("P"). text ());      });      //Set <p> element HTML code       $ ("Input:eq (2)"). Click (function () {             $ ("P"). HTML ("<strong> your favorite fruit is?</strong>");      });            //set the <p> element's text       $ ("Input:eq (3)"). Click (function () {& nbsp            $ ("P"). Text ("Your favorite fruit is?");      });        //Set <p> element text       $ ("InPUt:eq (4) "). Click (function () {             $ (" P "). Text (" <strong> your favorite fruit is?< /strong> ");      });        //Get button value of       $ ("Input:eq (5)"). Click (function () {      &NB Sp      alert ($ (this). Val ());      });         //Setting button value       $ ("Input:eq (6)"). Click (function () {    &NB Sp       $ (this). Val ("I was clicked!");      });    });  //]]>   </script>   code as follows: <script type= "Text/javascript" >  //<! [cdata[  $ (function () {      $ ("#address"). focus (function () {       //Address box get mouse spotlight             var txt_value =  $ (This). Val ();  //Get the value of the current text box             if (txt_value== "Please enter email address") {            &NBsp     $ (this). Val ("");              //if eligible, empty text box content            }  &nbsp ;    });       $ (#address). blur (function () {         //Address box lost Mouse focus       &N Bsp       var txt_value =  $ (This). Val ();  //Get current text box value             if (txt_value== "") {                $ (this). val ("Enter your email address");//If eligible, set content            }      &NBS P         $ ("#password"). focus (function () {            var txt_value =  $ (This). Val ();             if (txt_value== "Please enter mailbox password") {              &NBSP ; $ (this). Val ("");            }       });       $ ("#passwoRd "). blur (function () {              var txt_value =  $ (This). Val ();             if (txt_value== "") {                $ (this). val ("Please enter the mailbox secret Code ");            }       })  ;  //]]>   </script>     code as follows: <script type= "Text/javascript" >  //<! [cdata[  $ (function () {      $ ("#address"). focus (function () {       //Address box get mouse spotlight             var txt_value =  $ (This). Val ();  //Get the value of the current text box             if (txt_value==this.defaultvalue) {      &NBSP ;           $ (this). Val ("");              //if eligible, empty text box content            }  &nbsp ;    });       $ ("#address"). BLur (function () {         //Address box lost Mouse focus               var txt_val UE =  $ (This). Val ();  //Get current text box value             if (txt_value== "") {                $ (this). Val (this.defaultvalue);//If qualified, set content            }    &NB Sp  })         $ ("#password"). focus (function () {            var txt_v Alue =  $ (This). Val ();             if (txt_value==this.defaultvalue) {            &NBS P   $ (this). Val ("");            }       });       $ ("#password"). blur (function () {              var txt_value = &nbs p;$ (This). Val ();             if (txt_value== "") {        &NBsp       $ (this). Val (This.defaultvalue);            }       })  ;  //]]>   </script>     code as follows: <script type= "Text/javascript" >  //<! [cdata[  $ (function () {     //Set Radio dropdown box to select       $ ("Input:eq (0)"). Click (function () {&NB Sp           $ ("#single"). Val ("2");      });      //Set Multiple selection dropdown box selected       $ ("Input:eq (1)"). Click (function () {        &NBSP ;   $ ("#multiple"). val (["Option number 2nd", "option number 3rd"]);      });      //Set up Radio box and multiple selection box check       $ ("Input:eq (2)"). Click (function () {        &NB Sp    $ (": CheckBox"). Val (["Check2", "Check3"]);             $ (": Radio"). Val (["Radio2"]);      });        });  //]]>   </script>     Code as follows: <script type= "Text/javascript" >  //<! [cdata[  $ (function () {     //Set Radio dropdown box to select       $ ("Input:eq (0)"). Click (function () {&NB Sp           $ ("#single option"). Removeattr ("selected");  //Removal Properties selected             $ ("#single option:eq (1)"). attr ("selected", true); Set properties selected      });      //Set Multiple selection dropdown box selected       $ ("Input:eq (1)"). Click (function () {        &NBSP ;   $ ("#multiple option"). Removeattr ("selected");  //Removal Properties selected             $ ("#multiple Option:eq (2)"). attr ("selected", true);// Setting properties selected             $ ("#multiple Option:eq (3)"). attr ("selected", true);// Set properties selected      });      //Set up Radio box and multiple selection box check       $ ("Input:eq (2)"). Click (function () {        &NB Sp   $ (": CheckBox"). Removeattr ("checked"); Remove properties checked             $ (": Radio"). Removeattr ("checked"); Removing properties checked             $ (": Checkbox[value=check2]"). attr ("Checked", true);// Set properties checked             $ ("[Value=check3]:checkbox"). attr ("Checked", true);//Set properties checked             $ ("[Value=radio2]:radio"). attr ("Checked", true);/Set properties checked     & nbsp });     });  //]]>   </script>  : CheckBox indicates property is checkbox  

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.