I tried to dynamically change the position of an element which is defined in CSS with :after.
Using this:
$(function(){
$('div::after').css({'top':'20px'})
})
But it doesn’t work. Are there any ways to change the position?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. Content created by
:afteror:beforeis not part of the DOM and therefore cannot be selected or modified.If you have a look at this example fiddle and inspect the DOM in Firebug or similar you will see that the pseudo-element is not present in the DOM tree.
A potential solution would be to apply a class to the element you want to change, and to style that class appropriately in CSS:
See this fiddle for an example.