简体   繁体   English

如何使用Jquery删除伪元素

[英]How to delete Pseudo-elements with Jquery

How do I delete pseudo-elements with jquery. 如何使用jquery删除伪元素。
I tried before: 我之前尝试过:

$('.myclass a:after').hide();

and it's not working like that. 而且它不是那样工作的。

You can't modify the pseudo elements directly using scripts, but you can use some workarounds. 您不能直接使用脚本来修改pseudo elements ,但是可以使用一些解决方法。

One of them is to use a class like 其中之一是使用类似

 $('button').click(function() { $('.myclass a').addClass('hide-after'); }) 
 .myclass a:after { content: '++' } .hide-after:after { display: none } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="myclass"> <a>something</a> </div> <button>Test</button> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM