I have created my own plugin which has a custom script attached to it. I have added this in the correct manor like this:

add_action('admin_enqueue_scripts', 'add_search_script');
function add_search_script() {
    wp_register_script('search', plugins_url('search.js', __FILE__) );

If i add an alert to the top of the .js file, and then refresh the plugin page the alert appears. Simple alert like this:

alert ('test');

However if i try and hide something with js, noting happens?

I target a class like this:


Which has no effect? I have also tried:


Which again has no effect?

Any ideas on what could be the problem?


If your script is loading in the head of your admin page I would recommend wrapping your code in a document ready function

// wait till the entire dom is available before executing JS
// notice the $ this brings the $ into private scope if you wish to use it

    // put your page code here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.