If I have code like what is shown below, is there any way of avoiding the need of repeating the code over and over again?
$("#ClearSign1").click(function () {
signaturePad1.clear();
});
$("#ClearSign2").click(function () {
signaturePad2.clear();
});
$("#ClearSign3").click(function () {
signaturePad3.clear();
});
$("#ClearSign4").click(function () {
signaturePad4.clear();
});
$("#ClearSign5").click(function () {
signaturePad5.clear();
});
I can do this:
for(var i = 1; i < 6; i++) {
$("#ClearSign" + i).click(function () {
signaturePad1.clear();
});
}
But how do I handle the signaturePad1 variable? I need it to have the 1 updated to 2, 3, 4, 5 as looping through.