I have these elements - [.myCheckBox1, .myCheckBox2, ...]
And these elements - [.myCheckBoxList1, .myCheckBoxList2, ...]
How do I make the code pluggable so I don t have to duplicate the bulk?
理想的情况是,我要说的是:
[FUNCTION]
$( .myCheckBox1, .myCheckBox2, etc ).[FUNCTION]
$( .myCheckBoxList1, .myCheckBoxList2, etc ).[FUNCTION]
Code below is what I am wanting to modify:
<script type="text/javascript">
$(document).ready(function () {
$(".myCheckBox1").click(function () {
$(".myCheckBoxList1").change();
});
$(".myCheckBoxList1").change(function () {
var moneys = 0;
$(this).find(":checked").each(function () {
moneys += parseInt($(this).attr( value ));
});
$( .OMG ).html(moneys.toString());
});
});
</script>