[英]Hide Javascript or CSS with Javascript?
I am a complete newbie when it comes to JS. 关于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.
我实际上付钱给我为我写一些JS,但是我需要调整一些东西,而且我不希望仅仅做一些调整就雇用另一个人,所以我来找你寻求帮助。
The first issue is a wordpress plugin called Heads Up Bar. 第一个问题是一个名为Heads Up Bar的wordpress插件。 So fist thing I do is launch up the developer tools within Chrome and locate where its called on.
因此,我要做的第一件事就是启动Chrome中的开发人员工具,并找到调用它的位置。 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: 然后我去看看他创建的JS,它看起来像这样:
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. 接下来需要隐藏的是Google广告中的JS。 This appears in almost every post within wordpress but not in the homepage.
这几乎出现在wordpress中的每个帖子中,但不在首页中。 I know the name of the JS, meaning I know what the file is called:
我知道JS的名称,这意味着我知道文件的名称:
show_ads.js show_ads.js
and it is located in the product_detail.php file. 它位于product_detail.php文件中。 What will it take to hide this google ad using JS?
使用JS隐藏此Google广告需要什么?
Like I said, I am a bit new to this but I learn quickly. 就像我说的那样,我对此有些陌生,但很快就会学到。 I would appreciate any help.
我将不胜感激任何帮助。 Thanks!
谢谢!
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.post(ajaxurl, data, ...
的第三个参数是在AJAX请求完成时调用的方法。从页面加载完成AJAX请求起需要几毫秒的时间,因此顺序实际发生的情况是:
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. 注释掉
slideToggle
行,您应该就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.