How do I place the following javaScript in the <head> section of the WordPress Widgets API menu screen?

<script type="text/javascript">
    jQuery(window).load(function() {
        jQuery("#logocheckbox").change(function() {
            jQuery("#logocheckboxdiv").fadeToggle("slow");
        });
    });
</script>

2 Answers
2

Uncaught TypeError: Property '$' of object [object Object] is not a function

Are you positive you’re accessing the jQuery object correctly? You should look into how WordPress uses noConflict mode.

In the noConflict() mode, the global $ shortcut for jQuery is not available, but you can still use:

jQuery(document).ready(function(){
    jQuery(#somefunction) ...
});

As a footnote, as a developer, whether it’s for themes or plugins, you should make use of development tools that are at your disposal. Your browser likely has a Developer Tool or Console that will show you anything that’s wrong with your code. WordPress Debugging will also flag any errors that might still work, but are technically incorrect code.

Leave a Reply

Your email address will not be published. Required fields are marked *