gpt4 book ai didi

javascript - 如何使用 jQuery 删除伪内容后的元素

转载 作者:行者123 更新时间:2023-12-01 01:58:48 25 4
gpt4 key购买 nike

我正在编写以下代码。如何使用 jQuery 删除 .house 点击事件后的伪内容?

$('.remove').on('click', function() {
$('.house::after').css('display', 'none');
});
.house {
position: absolute;
right: 0px;
width: 0;
height: 0;
border-style: solid;
border-width: 0 80px 80px 0;
border-color: transparent red transparent transparent;
}

.house::after {
position: absolute;
content: "";
width: 80px;
height: 80px;
background: url("http://i.imgur.com/nceI30v.png");
background-repeat: no-repeat;
background-position: 75% 40%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="house"></div>
<button class="remove">Remove Pseudo</button>

最佳答案

试试这个代码...

$('.remove').on('click', function() {
$('.house').addClass('removing');
});
.house {
position: absolute;
right: 0px;
width: 0;
height: 0;
border-style: solid;
border-width: 0 80px 80px 0;
border-color: transparent red transparent transparent;
}

.house::after {
position: absolute;
content: "";
width: 80px;
height: 80px;
background: url("http://i.imgur.com/nceI30v.png");
background-repeat: no-repeat;
background-position: 75% 40%;
}
.removing:after{
display:none
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="house"></div>
<button class="remove">Remove Pseudo</button>

关于javascript - 如何使用 jQuery 删除伪内容后的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50780959/

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