Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hazratbilal0079/3c0d7af25aa4b2df040243aecb30cb55 to your computer and use it in GitHub Desktop.
Save hazratbilal0079/3c0d7af25aa4b2df040243aecb30cb55 to your computer and use it in GitHub Desktop.
Hide Previous Repeater Fields while adding New in Edit with jQuery
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
jQuery(document).ready(function($) {
// Hide all existing rows when the page loads
$('.jet-form-builder-repeater__row').hide();
// Attach a click event listener to the "Add New Comment" button
$('.jet-form-builder-repeater__new').on('click', function() {
// We need to wait for the new row to be added to the DOM
setTimeout(function() {
// Get the last added row (newly added)
var newRow = $('.jet-form-builder-repeater__row').last();
// Show the newly added row
newRow.show();
}, 100); // Adjust the timeout as necessary
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment