0

I am a complete newbie when it comes to JS. I actually paid someone to write some JS for me but I need to tweak some stuff and I don't feel like hiring another person for just a few tweaks so I come to you for help.

The first issue is a wordpress plugin called Heads Up Bar. So fist thing I do is launch up the developer tools within Chrome and locate where its called on. I come across this:

jQuery(document).ready(function($) {
var data = {
    action: 'ehu_show_bar',
    home: ehu_is_home_pg
};
jQuery.post(ajaxurl, data, function(response) {
    jQuery('body').prepend(response);
    if(ehu_animate === 'toggle'){
      jQuery('#ehu_bar').css('display', 'none');
      jQuery('#ehu_bar').slideToggle('fast');
    }

});

then I went and looked at the JS he created which looks a little like this:

jQuery(document).ready(function() {
            jQuery('#header').hide();
            jQuery('#sidebar').hide();
            jQuery('.main_navi').hide();
            jQuery('.category_navi_outer').hide();
            jQuery('.home_banner').hide();
            jQuery('.breadcrumb').hide();

So I create a new line called

jQuery('#ehu_bar').hide();

thinking it would be so easy. Obviously it didn't work. What am I missing? This plugin appears on every page of the site but sometimes its limited to only the homepage. What do I have to do now?

The next thing I need to hide is a JS from google ads. This appears in almost every post within wordpress but not in the homepage. I know the name of the JS, meaning I know what the file is called:

show_ads.js

and it is located in the product_detail.php file. What will it take to hide this google ad using JS?

Like I said, I am a bit new to this but I learn quickly. I would appreciate any help. Thanks!

3
  • Where did you create that new line? In the .ready(... block? Commented Nov 9, 2011 at 7:19
  • Also, consider opening a second question for the Google Ad Javascript issue. Commented Nov 9, 2011 at 7:21
  • You never really specify what you want to do with the Heads Up Bar... what specifically are you trying to accomplish? Commented Nov 9, 2011 at 8:23

1 Answer 1

1

The third parameter to the jQuery.post(ajaxurl, data, ... is a method that is called when the AJAX request is finished. It will take a few milliseconds from when the page loads to do the AJAX request, so the order of what will actually happen is:

jQuery('#ehu_bar').hide(); // from jQuery(document).ready(..

Then a few milliseconds later:

jQuery('#ehu_bar').slideToggle('fast'); // from ajax callback
// This line effectively is like calling jQuery('#ehu_bar').show() but with an animation

Comment out the slideToggle line and you should be OK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.