我有使用此代码打开一个弹出窗口:关闭弹出窗口,如果我点击另一个DIV
更新:
<ul class="grid cs-style-1">
<?php
$explainname = new wp_query(array ('post_type' => 'explainname'));
if ($explainname->have_posts()) : while ($explainname->have_posts()) : $explainname->the_post();
$explainname_icon = get_post_meta($post->ID,'explainname_icon', true);
$url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
$imageContent = get_the_content();
$stripped = strip_tags($imageContent, '<p> <a>'); //replace <p> and <a> with whatever tags you want to keep after the strip
?>
<li class="desktop">
<figure>
<img src="<?php echo $url; ?>" alt="<?php the_title(); ?>">
<figcaption>
<h3><?php the_title(); ?></h3>
<span style="text-align:right;font-size: 15px;"><?php echo $stripped; ?></span>
</figcaption>
</figure>
</li>
<li class="popup" onclick="myFunction<?php echo $post->ID; ?>()">
<figure>
<img src="<?php echo $url; ?>" alt="<?php the_title(); ?>">
<span class="popuptext" id="myPopup<?php echo $post->ID; ?>"><?php echo $stripped; ?></span>
</figure>
</li>
<script>
// When the user clicks on <div>, open the popup
function myFunction<?php echo $post->ID; ?>() {
var popup<?php echo $post->ID; ?> = document.getElementById("myPopup<?php echo $post->ID; ?>");
popup<?php echo $post->ID; ?>.classList.toggle("show");
}
</script>
<?php
endwhile; endif;
wp_reset_query();
?>
</ul>
我怎样才能关闭弹出窗口弹出窗口中?
我的意思是,我需要CLASE任何打开弹出,当我在新的div
我们都在猜测这里使用。没有办法测试这个,没有HTML。你可以发布弹出窗口的HTML和页面吗?否则,我认为你不会找到有用的答案。 –
查看我的更新,,我添加上面的代码 –