Skip to content Skip to sidebar Skip to footer

Wordpress Jquery Script Is Not Starting On One Instance With Jquery.noconflict Usage

I have Wordpress 2 instances: local and remote (remote should be very similar, it was mainly uploaded from local except from a few plugins). Code is using jQuery.noConflict method,

Solution 1:

Try the following. The function should fire on document.ready, but you can also call it whenever you like.

jQuery(function ($) {
    functioncustomizeWebUIForEmailSubscriberPlugin() {
        alert("customizeWebUIForEmailSubscriberPlugin");
        //format input button
        $('#elp_txt_email').removeClass('elp_textbox_class').addClass('form-control').addClass('full-width');

        //format input button
        $('#elp_txt_email').removeClass('elp_textbox_class').addClass('form-control').addClass('full-width');

        //format message text//jQuery('.elp_msg').removeClass('elp_msg').addClass('post-body');
        $('#elp_msg').addClass('message-format');
        //hide submit button
        $('#elp_txt_button').addClass('hide');

        //hide email label
        $('.elp_lablebox').addClass('hide');
    }
    $(document).ready(function() {
        customizeWebUIForEmailSubscriberPlugin();
    });
});

Edit:

In order to add jquery in WP, add this code to the bottom of your theme's functions.php file, before the closing php tag tat looks like this: ?>:

function pk_enqueue_scripts() {
    wp_enqueue_script('jquery');
}
add_action('pk_enqueue_scripts', 'wp_enqueue_scripts');

Solution 2:

The problem is that on both servers (local and remote) jQuery lib is attached in HEAD tag in different sequence. On my local machine: jQuery was attached after script.js and that worked. For remote: jQuery was attached after my script.js. I am not sure why it works in such way on my remote machine.

Answer : After adding code

<?php wp_enqueue_script("jquery"); ?>

right after HEAD tag, it works:).

Post a Comment for "Wordpress Jquery Script Is Not Starting On One Instance With Jquery.noconflict Usage"