Home › Forums › Backend Issues (wp-admin) › jQuery selector not working when trying to interact with an ACF field admin › Reply To: jQuery selector not working when trying to interact with an ACF field admin
Well, I feel a bit like an idiot, but for anyone else having this issue… The problem is that WP’s admin side runs jQuery in no-conflict mode – meaning you can’t use $ to access jQuery (amoungst other things).
My updated JS to affect the checkboxes looks like this:
jQuery(document).ready(function(){
// Check and uncheck children when parent is clicked
jQuery('ul.categorychecklist > li > label > :checkbox').change(function() {
jQuery(this).parent().parent().children('ul.children').children('li').children('label').children(':checkbox').attr('checked', this.checked);
});
});
Using jQuery instead of the already reserved $ selector fixes the problem, and allows the code to run properly.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.