How to add jquery plugin file in WP?

I’m tryig to used the mask plugin for jquery so that I can format my textbox.
but it seems this function is not working. I already tested it in a non-WP page it is working
but not when in WP. anyidea?

function mask_script(){
    wp_register_script('jquery.maskedinput', plugins_url('js/jquery.maskedinput.js', __FILE__ ));
    wp_enqueue_script('jquery.maskedinput');
}
add_action('wp_enqueue_script', 'mask_script');

UPDATE

Read More

I made it worked,. see the changes
I hope this can help someone like me in the future 🙂

function mask_script()
{

    wp_enqueue_script('jquery');
    wp_register_script('maskedinput1',plugins_url('/js/jquery.maskedinput.js', __FILE__ ));
    wp_enqueue_script('maskedinput1');
}
add_action('wp_enqueue_scripts', 'mask_script');

Related posts

Leave a Reply

1 comment

  1. Try to add a slash before js:

    wp_register_script('jquery.maskedinput', plugins_url('/js/jquery.maskedinput.js', __FILE__ )); 
    ----------------------------------------------------- ^ here -----------------
    

    since plugins_url function return the absolute URL to your plugins directory without the trailing slash.