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: