( function( api ) { // Extends our custom "book-publisher-agency" section. api.sectionConstructor['book-publisher-agency'] = api.Section.extend( { // No events for this type of section. attachEvents: function () {}, // Always make the section active. isContextuallyActive: function () { return true; } } ); } )( wp.customize ); jQuery(document).ready(function($) { $('#customize-control-book_publisher_agency_slide_number select').change(function() { var selectedSlides = $(this).val(); var currentSlides = $('[id^=book_publisher_agency_banner_background_image_sec]').length; if (selectedSlides > currentSlides) { for (var i = currentSlides + 1; i <= selectedSlides; i++) { // Add new settings and controls here dynamically } } else if (selectedSlides < currentSlides) { for (var i = selectedSlides; i < currentSlides; i++) { // Remove settings and controls here dynamically } } }); });