Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function($) {
- function checkAttributeLimit() {
- // Select only visible LI elements within the UL
- var visibleAttributeCount = $('.dokan-attribute-option-list > li:visible').length;
- if (visibleAttributeCount >= 2) {
- $('.add_new_attribute').hide();
- $('.cant_add_new').show();
- } else {
- $('.add_new_attribute').show();
- $('.cant_add_new').hide();
- }
- }
- // Initial check
- checkAttributeLimit();
- // Create a Mutation Observer instance
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
- checkAttributeLimit();
- }
- });
- });
- // Observer configuration
- var config = { attributes: true, childList: false, subtree: true };
- // Start observing the target element
- var target = $('.dokan-attribute-option-list')[0];
- observer.observe(target, config);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement