gpt4 book ai didi

html - CSS3 : Click on round div in the panel

转载 作者:行者123 更新时间:2023-11-28 02:53:25 25 4
gpt4 key购买 nike

我在 div 里面有一个面板 div 我有一个小的 round div。单击 panel div 时,它会重定向到另一个页面。

点击小的 round div 时,我在它下面看到了另一个 div。但是当我点击小的 round div 时,它也会重定向到另一个页面。我怎样才能避免这种情况?

$( document ).ready(function() {
$('.small_round_inner_div').click (function (){
$('.common_cateogory_status_edit_div').slideToggle('slow');
});
});
.panel_div{
width:300px;
height:300px;
background:#dee5e7;
position:relative;
cursor:pointer;
}

.small_round_main_div{
position:absolute;
right:15px;
top:15px;
}

.small_round_main_div .small_round_inner_div{
width:30px;
height:30px;
background:purple;
border-radius:50%;
}

.common_cateogory_status_edit_div {
background: #fff;
position: absolute;
right: 0px;
top: 35px;
border: thin #ced0d1 solid;
z-index: 1001;
width: 130px;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
display:none;
}
.common_cateogory_status_edit_div ul {
padding: 0;
margin: 0;
}
.common_cateogory_status_edit_div ul li {
padding: 5px 15px;
list-style-type: none;
color: #838383;
}
.common_cateogory_status_edit_div ul li:hover {
background: #edf1f2;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a href="https://www.google.com/">

<div class="panel_div">
Some Text
<div class="small_round_main_div">
<div class="small_round_inner_div"></div>
<div class="common_cateogory_status_edit_div fadeIn animated" >
<ul>
<li><span>Option 1</span></li>
</ul>
</div>
</div>
</div>
</a>

任何帮助都会很棒。

最佳答案

如果您对 DOM 树上的元素使用事件,您可能希望阻止默认行为并且可能还停止事件的传播。

$(document).ready(function() {
$('.small_round_inner_div').click(function(e) {
e.stopPropagation();
e.preventDefault()
$('.common_cateogory_status_edit_div').slideToggle('slow');
});
});
.panel_div {
width: 300px;
height: 300px;
background: #dee5e7;
position: relative;
cursor: pointer;
}

.small_round_main_div {
position: absolute;
right: 15px;
top: 15px;
}

.small_round_main_div .small_round_inner_div {
width: 30px;
height: 30px;
background: purple;
border-radius: 50%;
}

.common_cateogory_status_edit_div {
background: #fff;
position: absolute;
right: 0px;
top: 35px;
border: thin #ced0d1 solid;
z-index: 1001;
width: 130px;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
display: none;
}

.common_cateogory_status_edit_div ul {
padding: 0;
margin: 0;
}

.common_cateogory_status_edit_div ul li {
padding: 5px 15px;
list-style-type: none;
color: #838383;
}

.common_cateogory_status_edit_div ul li:hover {
background: #edf1f2;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a href="https://www.google.com/">
<div class="panel_div">
Some Text
<div class="small_round_main_div">
<div class="small_round_inner_div"></div>
<div class="common_cateogory_status_edit_div fadeIn animated">
<ul>
<li>
<span>Option 1</span>
</li>
</ul>
</div>
</div>
</div>
</a>

关于html - CSS3 : Click on round div in the panel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46564126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com