(function ($) { // Ensure parent category is bold only if it has children $('.categorychecklist li').each(function () { var $this = $(this); if ($this.children('.children').length) { $this.children('label').css('font-weight', 'bold'); } }); // Collapsible subcategories $('.categorychecklist li').each(function () { if ($(this).children('.children').length) { $(this) .children('.children') .hide(); $(this) .children('label') .before( '[+] ' ); } }); $('.categorychecklist').on('click', 'a.toggle-subcategories', function (e) { e.preventDefault(); e.stopPropagation(); var $this = $(this); $this.parent() .children('.children') .slideToggle('fast', function () { $this.toggle(); $this.siblings('.toggle-subcategories').toggle(); }); }); // Auto-select parent categories when child is selected $('.categorychecklist').on('change', ':checkbox', function () { var $this = $(this); if ($this.is(':checked')) { // Check all parent categories $this.parents('li').children('input:checkbox').prop('checked', true); } else { // Uncheck child categories if parent is unchecked $this.closest('li').find('input:checkbox').prop('checked', false); } }); // Prevent default category from selecting unrelated categories $('.categorychecklist input[type="checkbox"]').on('change', function () { const defaultCategoryId = 1; // Replace with the ID of your default category (General Knowledge Mcqs) if ($(this).val() == defaultCategoryId) { if ($(this).is(':checked')) { // Uncheck all other categories $('.categorychecklist input[type="checkbox"]') .not(this) .prop('checked', false); // Clear 'Make Primary' for unrelated categories $('.categorychecklist li').each(function () { if ( $(this).find('input[type="checkbox"]').prop('checked') === false ) { $(this).find('.cat-item-action').remove(); } }); } } }); // Update 'Make Primary' visibility based on checked categories $('.categorychecklist input[type="checkbox"]').on('change', function () { const $parentLi = $(this).closest('li'); const isChecked = $(this).prop('checked'); if (isChecked) { $parentLi.find('.cat-item-action').show(); } else { $parentLi.find('.cat-item-action').remove(); } }); })(jQuery); {"id":26043,"date":"2018-05-16T17:06:26","date_gmt":"2018-05-16T12:06:26","guid":{"rendered":"https:\/\/pakmcqs.com\/?p=26043"},"modified":"2018-05-16T17:06:26","modified_gmt":"2018-05-16T12:06:26","slug":"who-has-become-the-first-country-to-win-test-match-against-10-different-test-playing-nations","status":"publish","type":"post","link":"https:\/\/pakmcqs.com\/pakistan-current-affairs-mcqs\/who-has-become-the-first-country-to-win-test-match-against-10-different-test-playing-nations","title":{"rendered":"Who has become the first country to win test match against 10 different test playing nations?"},"content":{"rendered":"
A. Pakistan<\/strong> Submitted by: Kashif Ashraf<\/b><\/p>\n","protected":false},"excerpt":{"rendered":" A. Pakistan B. Australia C. India D. New Zealand Submitted by: Kashif Ashraf<\/p>\n","protected":false},"author":922,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":{"0":"post-26043","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-pakistan-current-affairs-mcqs"},"plaintext":"A. Pakistan<\/strong>\nB. Australia\nC. India\nD. New Zealand\nSubmitted by: Kashif Ashraf\n","yoast_head":"\n
\nB. Australia
\nC. India
\nD. New Zealand<\/p>\n