[英]How can I hide one div in Wordpress using jQuery, and show it when another div is hidden?
Somehow this doesn't work.不知何故,这不起作用。 The #autoverkocht should be hidden by default, unless the.b-car-info__price is hidden, #autoverkocht should be shown.默认情况下应该隐藏#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');
}
It's either the jQuery above or the functions.php code below that doesn't work.它是上面的 jQuery 或下面的函数。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
);
} }
You can use inline styling like below:您可以使用如下内联样式:
<div id='autoverkocht' style='display: none;'>
</div>
or use css styling like this:或使用 css 样式如下:
#autoverkocht{
display: none;
}
And in the jquery do this:在 jquery 中执行以下操作:
<script>
jQuery(document).ready(function($){
if($('.b-car-info__price).is(":hidden")){
$('#autoverkocht').show();
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.