- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to manipulate CSS pseudo-elements ::before and ::after using jQuery?
To manipulate CSS pseudo elements using the hover() function. You can try to run the following code to learn how to manipulate CSS pseudo-elements −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/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>
- Related Articles
- The ::before and ::after Pseudo-element in CSS
- Various tricks for :before pseudo elements using position property in CSS
- CSS :before pseudo-element
- CSS :after pseudo-element
- Pseudo-elements and CSS Classes
- CSS Pseudo Elements
- How jQuery selects elements using CSS?
- How to insert content after each of the matched elements using jQuery?
- How to change CSS using jQuery?
- How to append an element before an element using jQuery?
- How to apply CSS properties using jQuery?
- How to apply CSS style using jQuery?
- How animate(), hide and show elements using jQuery?
- How to add space before and after specific character using regex in Python?
- What are the methods in jQuery to manipulate attributes?

Advertisements