php - 如何使用 jQuery 在 Wordpress 中隐藏一个 div,并在隐藏另一个 div 时显示它?
问题描述
不知何故,这不起作用。默认情况下应该隐藏#autooverkocht,除非隐藏 .b-car-info__price,否则应该显示#autooverkocht。
jQuery(document).ready(function($){
$("#autoverkocht").css({
display: "none",
visibility: "hidden"
});
})
if($('.b-car-info__price').is(":hidden")){
$('#autoverkocht').css('visibility', 'visible');
}
要么是上面的 jQuery,要么是下面的 functions.php 代码不起作用。
add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
wp_enqueue_script(
'your-script', // name your script so that you can attach other scripts and de-register, etc.
get_template_directory_uri() . '/js/autoverkocht.js', // this is the location of your script file
array('jquery') // this array lists the scripts upon which your script depends
);
}
解决方案
推荐阅读
- c# - 我如何将一些数据作为文本添加到已经有数据的文本文件中
- c++ - 将数组的容量声明为类中它自己的变量的好处?
- sass - Sass:在 & 2+级嵌套前面添加元素
- python - Python3 PyQT5 浮点变量到 LineEdit
- android - 在选定位置显示图像并在回收站视图中隐藏所有其他以前的图像
- flutter - Flutter 网页黑屏
- laravel - Laravel 5.8 与 Bootstrap 3
- python - 试图获得运行列表的总和
- php - 为什么我不能在 smarty 中使用前缀匹配编写 if 语句?
- python - 为 geopandas 图添加标签或位置