使用jQuery删除:: after CSS样式 [英] Remove an ::after CSS style using jQuery

查看:1472
本文介绍了使用jQuery删除:: after CSS样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CSS文件,该文件针对类('view-performance')指定了:after样式

I have a CSS file that specifies an :after style against a class ('view-performance')

使用jQuery(因为我的JS文件包含业务逻辑),如何根据业务逻辑删除:after样式?

Using jQuery (because my JS file contains the business logic), how can I remove the :after style based on the business logic?

推荐答案

您无法使用jQuery达到伪元素!

但是您可以使用 css 进行操作,并使用.addClass()/.removeClass()

But you can do it with css, and manipulate it using .addClass() / .removeClass()

下面是一个示例,如何通过添加CSS类来删除伪元素:after:

Here is an example how can you remove pseudo element :after by adding css class:

您的JS:

$('.view-performance').addClass('without-after-element');

您的CSS:

.view-performance:after {
  content: 'i go after';
}
.view-performance.without-after-element:after {
  content: none;
}

您还可以检查以下问题:

You may also check this question:

stackoverflow.com/questions/17788990/access-the-css-after -selector-with-jquery

这篇关于使用jQuery删除:: after CSS样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆