如何使用jQuery操作CSS伪元素:: before和:: after?
使用hover()函数处理CSS伪元素。您可以尝试运行以下代码来学习如何操作CSS伪元素-
示例
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('span').hover(function(){
$(this).addClass('change').attr('data-content','bar');
});
});
</script>
<style>
span.change:after {
content: attr(data-content) ' This is demo text.';
}
</style>
</head>
<body>
<p>Place cursor below...</p>
<span>foo</span>
</body>
</html>热门推荐
10 男孩上学祝福语简短的
11 企业英语祝福语大全简短
12 夫妻之间生日祝福语简短
13 新年祝福语老公的简短
14 元旦祝福语简短短句
15 徒弟生日的简短祝福语
16 抗疫中国祝福语简短
17 早餐店祝福语简短霸气
18 贺卡祝老师祝福语简短