Full selection of jquery operations TreeView, Reverse Selection

Source: Internet
Author: User

1 <asp:treeview id="TV" runat="server" Expanddepth="2" showcheckboxes="all"2         showlines="True" imageset="Msdn" > 3     </asp:TreeView>

JavaScript Part Code

1 $(2     function () {3         //Top Choice4$ ("a[id^= ' CONTENT_TVT ')". each (function(I, item) {5             varV = $ (item). attr ("href"). Split (' \ ') [3].replace (/\\\\/g, ' | '));6$( This). attr ("Data", v);7$($("#" + $( This). attr ("id"). Replace ("TVT", "TVN") + "checkbox"). attr ("Data")., v);8             varVV = v.split (' | ')). length;9             if(VV = = 1) {Ten$( This). attr ("href", "#"). attr ("onclick", "fun1 ('" + $ ( This). attr ("id") + "', '" + V + "')"); One             } A             Else if(VV = = 2) { -$( This). attr ("href", "#"). attr ("onclick", "fun2 ('" + $ ( This). attr ("id") + "', '" + V + "')"); -}Else if(VV = = 3) { the$( This). attr ("href", "#"). attr ("onclick", "fun3 ('" + $ ( This). attr ("id") + "', '" + V + "')"); -             } -         }); -         //Operation CheckBox +$ (": CheckBox"). each (function(I, item) { -$( This). attr ("onclick", "Fun ('" + $ ( This). attr ("id") + "')"); +         }); A     }); at     //Operation CheckBox -     functionFun (con) { -         varVV = $ ("#" + con). attr ("Data"). Split (' | ')). length; -         if(VV = = 1) { - fun4 (con); -         } in         Else if(VV = = 2) { - fun5 (con); to}Else if(VV = = 3) { + fun6 (con); -         } the     } *     functionFun4 (con) { $         if($ ("#" + con). Is (": Checked")) {Panax Notoginseng$ (": CheckBox"). attr ("Checked", "checked"); -         } the         Else { +$ (": CheckBox"). Removeattr ("checked")); A         } the     } +     functionFun5 (con) { -         varData = $ ("#" + con). attr ("Data")); $         varDataarr = Data.split (' | ')); $         if($ ("#" + con). Is (": Checked")) { -$ (": checkbox[data^= '" + Data + "']"). attr ("Checked", "checked"); -$ (": Checkbox[data= '" + dataarr[0] + "']"). attr ("Checked", "checked"); the$ (": checkbox[data^= '" + dataarr[0] + "|"] "). eachfunction(I, item) { -                 if(!$( This). Is (": Checked")) {Wuyi$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); the                 } -             }); Wu         } -         Else { About$ (": checkbox[data^= '" + Data + "']"). Removeattr ("Checked"); $$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); -         } -     } -     functionfun6 (con) { A         varData = $ ("#" + con). attr ("Data")); +         varDataarr = Data.split (' | ')); the         if($ ("#" + con). Is (": Checked")) { -$ ("#" + con). attr ("Checked", "checked"); $$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). attr ("Checked", "checked"); the$ (": checkbox[data^= '" + dataarr[0] + "|" + dataarr[1] + "|"] "). eachfunction(I, item) { the                 if(!$( This). Is (": Checked")) { the$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). Removeattr ("Checked"); the                 } -             }); in$ (": Checkbox[data= '" + dataarr[0] + "']"). attr ("Checked", "checked"); the$ (": checkbox[data^= '" + dataarr[0] + "|"] "). eachfunction(I, item) { the                 if(!$( This). Is (": Checked")) { About$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); the                 } the             }); the         } +         Else { -$ ("#" + con). Removeattr ("checked")); the$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). Removeattr ("Checked");Bayi$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); the         } the     } -     //manipulating Text -     functionfun1 (ID, data) { the         if($ ("#" + id.replace ("TVT", "TVN") + "CheckBox"). Is (": Checked")) { the$ (": CheckBox"). Removeattr ("checked")); the         } the         Else { -$ (": CheckBox"). attr ("Checked", "checked"); the         } the     } the     functionfun2 (ID, data) {94         varDataarr = Data.split (' | ')); the         if($ ("#" + id.replace ("TVT", "TVN") + "CheckBox"). Is (": Checked")) { the$ (": checkbox[data^= '" + Data + "']"). Removeattr ("Checked"); the$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked");98         } About         Else { -$ (": checkbox[data^= '" + Data + "']"). attr ("Checked", "checked");101$ (": Checkbox[data= '" + dataarr[0] + "']"). attr ("Checked", "checked");102$ (": checkbox[data^= '" + dataarr[0] + "|"] "). eachfunction(I, item) {103                 if(!$( This). Is (": Checked")) {104$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); the                  }106             });107         }108     }109     functionfun3 (ID, data) { the         varDataarr = Data.split (' | '));111         if($ ("#" + id.replace ("TVT", "TVN") + "CheckBox"). Is (": Checked")) { the$ ("#" + id.replace ("TVT", "TVN") + "CheckBox"). Removeattr ("Checked");113$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). Removeattr ("Checked"); the$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); the         } the         Else {117$ ("#" + id.replace ("TVT", "TVN") + "CheckBox"). attr ("Checked", "checked");118$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). attr ("Checked", "checked");119$ (": checkbox[data^= '" + dataarr[0] + "|" + dataarr[1] + "|"] "). eachfunction(I, item) { -                 if(!$( This). Is (": Checked")) {121$ (": Checkbox[data= '" + dataarr[0] + "|" + dataarr[1] + "']"). Removeattr ("Checked");122                 }123             });124$ (": Checkbox[data= '" + dataarr[0] + "']"). attr ("Checked", "checked"); the$ (": checkbox[data^= '" + dataarr[0] + "|"] "). eachfunction(I, item) {126                 if(!$( This). Is (": Checked")) {127$ (": Checkbox[data= '" + dataarr[0] + "']"). Removeattr ("Checked"); -                 }129             }); the         }131     } the</script>

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.