Replacing the number part with the number of each loop iteration i.e. booking_customer_date_of_birth_1_display becomes booking_customer_date_of_birth_2_display etc…
However have tried putting this in a for-loop but it does not work.
for($i = 2; i <= 6; i++)
{
if($(‘#booking_customer_date_of_birth_’ + i + ‘display’).length > 0)
{
$('#booking_customer_date_of_birth’ + i + ‘display’).click(function()
{
$(this).hide();
$('#booking_customer_date_of_birth’ + i + ‘_editable’).show();
});
}
}
Can anyone suggest how this can be done in JQuery.
When the function being passed to clicked is called i will be 6. In order to have the correct vale requires a closure with self invocation and a binding the state of i. This has nothing to do with jQuery but JavaScript 101. That is why you should learn JavaScript before jQuery…