JQuery adds and deletes JavaScript code for the text content at the div layer of the table and selects JS Code for the effect in the select-like personality drop-down box.

Source: Internet
Author: User

In the morning, a ticket booking page is reconstructed. The page has the function of adding and deleting flight attendants, so JQuery's. remove () attributes and. the append () attribute writes a javascript code that adds or deletes the text content of the div layer. You can run the following code to demonstrate the effect. The Code has two JS effects in total:
1. add or delete the text content of the div layer.
2. Select the effect from the drop-down list.
Online Demo: http://mj.588cy.com/jquery/24.html
[Html]
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> MJBlog (mj.588cy.com) </title>
<Style type = "text/css">
Em {font-style: normal ;}
* {Margin: 0; padding: 0; font-size: 12px; list-style: none; border: 0 ;}
Body {margin: 0px; padding: 0px; background-color: # f0f0f0; font-family: Arial, Helvetica, sans-serif ;}
A {text-decoration: none ;}
. Top {width: 970px; height: 30px; border-bottom: 1px solid # dbdbdb; margin: 0px auto ;}
. Logo {width: 300px; height: 30px; line-height: 30px; float: left; font-size: 14px; margin: 0px 5px ;}
. Logo a {color: #666666 ;}
. Denglu {height: 30px; line-height: 30px; float: right; font-size: 14px ;}
. Denglu a {color: #666666; margin: 0px 10px ;}
. Clear {display: block; height: 0px; line-height: 0px; font-size: 0px; clear: both ;}
 
. Box {width: 950px; height: auto; margin: 0px auto; border-top: 1px solid # f9f9f9; padding: 30px 10px ;}
. Ck {width: 950px; height: auto; padding-top: 10px ;}
. Ck_list {width: 950px; height: 22px; padding: 10px 0px; color: #555555; font-size: 12px; border-bottom: 1px solid # dddddddd ;}
. Ck_list input {color: #555555; overflow: hidden ;}
. Ck_list_xm {height: 22px; display: block; padding: 0px 7px 0px 14px; line-height: 22px; float: left ;}
. Ck_list_xm em {color: # ff005b; font-family: ""; margin-left: 10px ;}
. Ck_input_a {width: 100px; height: 20px; float: left; border: 1px solid # bababa; padding: 0px 2px; _ height: 17px; _ padding: 3px 2px 0px 2px; margin-right: 4px ;}
. Ck_list_lb,. span_fd {width: 98px ;}
. Ck_list_zj,. span_fd_zj {width: 68px ;}
. Ck_list_bx,. span_fd_bx {width: 58px ;}
. Ck_list_fd {height: 20px; border: 1px solid # bababa; display: block; float: left; background: url (http://mj.588cy.com/img/bg_mj.png) no-repeat right-620px ;}
. Touming_jq {position: relative; z-index: 1 ;}
. Ck_input_ B {width: 70px ;}
. Ck_input_c {width: 40px ;}
. Ck_input_e {width: 30px ;}
. Ck_input_ B ,. ck_input_c ,. ck_input_e {float: left; border: 0px; height: 20px; padding: 0px 3px; _ height: 17px; _ padding: 3px 3px 0px 3px; cursor: pointer ;}
. Span_lb {width: 22px; height: 20px; float: left; cursor: pointer ;}
. Span_fd ,. span_fd_zj ,. span_fd_bx {height: auto; border-width: 0px 1px 1px 1px; border-style: solid; border-color: # bababa; position: absolute; left:-1px; top: 21px; z-index: 999; display: none; background-color: # FFFFFF ;}
. Span_fd span {width: 92px ;}
. Span_fd_zj span {width: 62px ;}
. Span_fd_bx span {width: 52px ;}
. Span_fd span,. span_fd_zj span,. span_fd_bx span {height: 20px; line-height: 20px; padding: 2px 3px; display: block; cursor: pointer ;}
. Ck_input_d {width: 165px; height: 20px; float: left; border: 1px solid # bababa; padding: 0px 2px; _ height: 17px; _ padding: 3px 2px 0px 2px; margin: 0px 36px 0px 6px ;}
. Shanchu {width: 14px; height: 14px; margin: 3px 17px; display: block; float: right; background: url (http://mj.588cy.com/img/bg_mj.png) no-repeat 0px-661px; cursor: pointer ;}
 
. Zj {width: 922px; height: 22px; padding: 10px 14px; font-size: 12px ;}
. Zj_an {display: block; width: 83px; height: 22px; float: left; background: url (http://mj.588cy.com/img/bg_mj.png) no-repeat 0px-695px; cursor: pointer ;}
. Zj_ts {display: block; height: 22px; float: left; color: # ff075b; line-height: 22px; padding-left: 10px ;}
. Zj_input_a {float: right; margin: 5px 5px 0px 0px; _ margin: 1px 1px 0px 0px ;}
. Zj_bc {display: block; height: 22px; float: right; line-height: 22px; color: #555555 ;}
</Style>
<Script type = "text/javascript" src = "http://mj.588cy.com/img/jquery-1.2.6.min.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ (". Jq_ck,. jq_val"). click (function (){
$ (This). siblings (". jq_lb"). slideToggle (100 );
$ (". Ck_list_fd"). removeClass ("touming_jq ");
$ (This). parent (". ck_list_fd"). addClass ("touming_jq ")
});

$ ("*"). Click (function (){
$ (". Jq_lb"). hide ();
});

$ (". Jq_lb span"). hover (function (){
Certificate (this).css ({"background-color": "# 0066CC", "color": "# FFFFFF "})
}, Function (){
Certificate (this).css ({"background-color": "# ffffff", "color": "#555555 "})
});

$ (". Jq_lb span"). click (function (){
$ (This). parent (). siblings (". jq_val" ).val(((this).html ())
});
 
$ (". Shanchu"). click (function (){
If ($ (". ck_list"). size ()> 1 ){
$ (This). parent (). remove ();
} Else {
$ (". Zj_ts" ).html ("at least one passenger is retained for an order ");
}
});

$ (". Zj_an"). click (function (){
$ (". Ck"). append ($ (". ck_list: first"). clone (true ));
$ (". Zj_ts" ).html ("");
});
});
</Script>
</Head>
 
<Body>
<Div class = "top">
<Div class = "logo"> <a href = "http://mj.588cy.com"> MJBlog </a> </div>
<Div class = "denglu"> <a href = "#"> logon </a> <a href = "#"> Registration </a> </div>
<Div class = "clear"> </div>
</Div>
 
<Div class = "box">
<Div class = "ck">
<Div class = "ck_list">
<Span class = "ck_list_xm"> name <em> * </em> </span>
<Input name = "" type = "text" class = "ck_input_a"/>
<Span class = "ck_list_lb ck_list_fd">
<Input name = "" type = "text" class = "ck_input_ B jq_val" value = "adult (> 12 years old)" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd jq_lb"> <span> adult (> 12 years old) </span> <span> children (2-12 years old) </span> </div>
</Span>

<Span class = "ck_list_xm"> credential number <em> * </em> </span>
<Span class = "ck_list_zj ck_list_fd">
<Input name = "" type = "text" class = "ck_input_c jq_val" value = "ID card" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd_zj jq_lb"> <span> ID card </span> <span> passport </span> <span> others </span> </div>
</Span>
<Input name = "" type = "text" class = "ck_input_d"/>
 
<Span class = "ck_list_xm"> Insurance </span>
<Span class = "ck_list_bx ck_list_fd">
<Input name = "" type = "text" class = "ck_input_e jq_val" value = "0" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd_bx jq_lb"> <span> 0 </span> <span> 1 </span> <span> 2 </span> </div>
</Span>
<Span class = "ck_list_xm"> $20/copy </span>
<Span class = "shanchu"> </span>
<Span class = "clear"> </span> </div>
 
<Div class = "ck_list">
<Span class = "ck_list_xm"> name <em> * </em> </span>
<Input name = "" type = "text" class = "ck_input_a"/>
<Span class = "ck_list_lb ck_list_fd">
<Input name = "" type = "text" class = "ck_input_ B jq_val" value = "adult (> 12 years old)" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd jq_lb"> <span> adult (> 12 years old) </span> <span> children (2-12 years old) </span> </div>
</Span>

<Span class = "ck_list_xm"> credential number <em> * </em> </span>
<Span class = "ck_list_zj ck_list_fd">
<Input name = "" type = "text" class = "ck_input_c jq_val" value = "ID card" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd_zj jq_lb"> <span> ID card </span> <span> passport </span> <span> others </span> </div>
</Span>
<Input name = "" type = "text" class = "ck_input_d"/>
 
<Span class = "ck_list_xm"> Insurance </span>
<Span class = "ck_list_bx ck_list_fd">
<Input name = "" type = "text" class = "ck_input_e jq_val" value = "0" onmousedown = "return false"/>
<Div class = "span_lb jq_ck"> </div>
<Div class = "clear"> </div>
<Div class = "span_fd_bx jq_lb"> <span> 0 </span> <span> 1 </span> <span> 2 </span> </div>
</Span>
<Span class = "ck_list_xm"> $20/copy </span>
<Span class = "shanchu"> </span>
<Span class = "clear"> </span> </div>
</Div>
 
<Div class = "zj">
<Span class = "zj_an"> </span>
<Span class = "zj_ts"> </span>
<Span class = "zj_bc"> Save to common contacts </span>
<Input name = "" type = "checkbox" value = "" class = "zj_input_a"/>
<Span class = "clear"> </span>
</Div>
</Div>
</Body>
</Html>

Related Article

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.