A simple jquery multi-choice drop-down box (self-writing) _ jquery-js tutorial

Source: Internet
Author: User
I want to find a plug-in for use on the Internet. However, the plug-ins on the Internet seem messy. I have referred to some plug-ins on the Internet, I used jquery to write a multi-choice drop-down box. Today, I want to use a multi-choice drop-down box to find a plug-in on the Internet. However, the plug-ins on the Internet seem messy, I have referenced some plug-ins on the Internet and wrote a multi-choice drop-down box using jquery. js is relatively simple. The Code is as follows.

Js Code

The Code is as follows:


(Function (){
$. Fn. extend ({
Checks_select: function (options ){
Jq_checks_select = null;
$ (This). click (function (e ){
Jq_check = $ (this );
// Jq_check.attr ("class ","");
If (jq_checks_select = null ){
Jq_checks_select = $ ("

"). InsertAfter (jq_check );
$. Each (options, function (I, n ){
Check_p = $ ("

"+ N +"

"). AppendTo (jq_checks_select );
Check_box = check_p.children ();
Check_box.click (function (e ){
// Jq_check.attr ("value", $ (this). attr ("value "));

Temp = "";
$ ("Input: checked"). each (function (I ){
If (I = 0 ){
Temp = $ (this). attr ("value ");
} Else {
Temp + = "," + $ (this). attr ("value ");
}
});
Jq_check.attr ("value", temp );
E. stopPropagation ();
});
});
} Else {
Jq_checks_select.toggle ();

}
E. stopPropagation ();
});
$ (Document). click (function (){
Jq_checks_select.hide ();
});
// $ (This). blur (function (){
// Jq_checks_select.css ("visibility", "hidden ");
// Alert ();
//});
}
})

}) (JQuery );


Html

The Code is as follows:




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.