JQuery implementation example similar to Taobao shopping cart full selection status

Source: Internet
Author: User


Copy codeThe Code is as follows:
<! 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> I am an investor </title>
<Script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<Style type = "text/css"> * {margin: 0; padding: 0; color: #727272; font-size: 12px; outline: none ;}
Table {border-collapse: collapse; border-spacing: 0 ;}
A {color: # 3A3A3A; text-decoration: none; color: #575757 ;}
A: hover {text-decoration: none ;}
. L_user. mailspage {background: # fff ;}
. L_user. mailspage. mail {padding-bottom: 25px ;}
. L_user. mailspage. mail p {margin: 0px 0 5px 5px; padding-top: 5px ;}
. L_user. mailspage. mail table {width: 745px; text-align: center ;}
. L_user. mailspage. mail. table_box {width: 745px; border: 1px solid # dddddddd; margin: 0 0 0px 10px ;}
. L_user. mailspage. mail. firsttr {border-top: none ;}
. L_user. mailspage. mail td {height: 30px; line-height: 30px ;}
. L_user. mailspage. sendmsm {margin-top: 25px ;}
. L_user. mailspage. sendmsm div {margin: 0 0 10px 40px ;}
. L_user. mailspage. sendmsm div label {width: 50px; text-align: right; display: inline-block; vertical-align: middle; margin-right: 5px ;}
. Rochelle user. mailspage. sendmsm div input {margin-right: 5px; border: 1px solid # ccc; height: 20px; line-height: 20px; padding-left: 5px; vertical-align: middle; border-radius: 5px ;}
. Rochelle user. mailspage. sendmsm div textarea {width: 270px; height: 130px; vertical-align: top; border: 1px solid # ccc; padding: 5px; border-radius: 5px ;}
. Rochelle user. mailspage. sendmsm div a {width: pixel PX; height: 35px; display: inline-block; background: url (.. /images/L_btn0615.jpg) no-repeat-8px-72px; vertical-align: middle; margin-right: 10px ;}
. L_user. mailspage. sendmsm div a: hover {background-position:-8px-115px ;}
. L_user. mailspage {width: 768px; border: 1px solid # E5E5E5; float: left; overflow: hidden ;}
. L_user. mailspage. loantab {background: # fff; border-bottom: 1px solid # E5E5E5 ;}
. Rochelle user. mailspage. loantab a {width: pixel PX; height: 40px; border: 1px solid # E5E5E5; border-bottom: none; display: inline-block; text-align: center; border-left: none; border-top: none; line-height: 40px; color: #464646; font-weight: bold ;}
. L_user. mailspage. loantab a. c {background: # F4F4F4; color: # CF161C ;}
. Rochelle user. mailspage. mail. markbtn a {width: 64px; height: 27px; background: url (.. /images/L_btn0615.jpg) no-repeat-4px-6px; display: inline-block; text-align: center; line-height: 25px; vertical-align: middle ;}
. L_user. mailspage. mail. markbtn a: hover {background-position:-4px-37px ;}
. Rochelle user. mailspage. mail. firsttr {background: # F9F9F9; border-bottom: 1px solid # dddddddd; border-top: 1px solid # dddddddd; height: 20px; line-height: 20px;} </style>
</Head>

<Body>

<Div class = "L_user clear-fix">

<Div class = "mailspage">
<Div class = "loantab"> <a href = "javascript: void (0)" class = "c"> inbox </a> <a href = "javascript: void (0) "> sent </a> <a href =" javascript: void (0) "> sent message </a> </div>
<Div class = "mail">
<P class = "markbtn"> <a href = "javascript: void (0)" class = "deletebtn"> Delete </a> <a href = "javascript: void (0) "> mark as read </a> <a href =" javascript: void (0) "> mark as unread </a> </p>
<Div class = "table_box">
<Table>
<Tr id = "titletr">
<Td class = "firsttr"> <input type = "checkbox" id = "allcheckbox"/> </td>
<Td class = "firsttr"> </td>
<Td class = "firsttr"> sender </td>
<Td class = "firsttr"> title </td>
<Td class = "firsttr"> sending time </td>
</Tr>
<Tr>
<Td> <input type = "checkbox"/> </td>
<Td> 3 </td>
<Td> XXX </td>
<Td> XXX </td>
<Td> XXX </td>
</Tr>
<Tr>
<Td> <input type = "checkbox"/> </td>
<Td> 3 </td>
<Td> XXX </td>
<Td> XXX </td>
<Td> XXX </td>
</Tr>
<Tr>
<Td> <input type = "checkbox"/> </td>
<Td> 3 </td>
<Td> XXX </td>
<Td> XXX </td>
<Td> XXX </td>
</Tr>
</Table>
<P class = "page"> 0 <a href = "javascript: void (0)"> homepage </a> <a href = "javascript: void (0) "> previous page </a> <a href =" javascript: void (0) "> next page </a> <a href =" javascript: void (0) "> last page </a> </p>
</Div>
</Div>

</Div>
</Div>

Copy codeThe Code is as follows:
<Script type = "text/javascript"> // Delete selected items:
$ (". Markbtn. deletebtn"). click (function (){
$ (". Table_box tr"). each (function (){
If ($ (this). find ("input"). attr ("checked") & $ (this). index ()! = 0 ){
$ (This). remove ();
}
})
})
$ ("# Allcheckbox"). click (function (){
If ($ (this). attr ("checked ")){
$ (". Table_box td input"). attr ("checked", "checked ");
} Else {
$ (". Table_box td input"). attr ("checked ","")
}
})

$ (". Table_box input"). not ("# allcheckbox"). click (function (){
$ (". Table_box input"). not ("# allcheckbox"). each (function (){
If ($ (". table_box input [type = 'checkbox']: checked "). not ("# allcheckbox "). length = $ (". table_box tr "). not ("# titletr "). length ){
$ ("# Allcheckbox"). attr ("checked", "checked ");
} Else {
$ ("# Allcheckbox"). attr ("checked ","");
}
})

}) </Script>
</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.