Put the Code directly. It is best to use the image in jquery mobile for on.png and off.png.
// Similar to the jQuery mobile Select control // use box as the container id, _ id indicates the Control id, selectvalue indicates the selected Value, and Value indicates the current Value of function SelectBox (box, _ id, selectvalue, value) {if (Value! = Selectvalue) {$ ("#" + box).html ("");$("#off" + _id).css("width","82px");}else{$("#" + box).html(""); $ (" # On "+ _id1_.css (" width "," 82px ");} $ (" # on "+ _ id ). click (function () {$ ("# on" + _ id ). animate ({width: "0px"}, 100); $ ("# off" + _ id ). animate ({width: "82px"}, 100); $ ("#" + _ id ). val (Value) ;}); $ ("# off" + _ id ). click (function () {$ ("# on" + _ id ). animate ({width: "82px"}, 100); $ ("# off" + _ id ). animate ({width: "0px"}, 100); $ ("#" + _ id ). val (selectvalue );});}
Usage:
<Script type = "text/javascript"> CheckBox ("q", "a", 1, 0); </script>