I'm having an issue with a CSS after element that is supposed to function as a button to take the user back to the top of the page. However, I can't seem to get the hover state and jQuery click function to work properly. I'm wondering if there might be a syntax error that I'm overlooking?
Here's my HTML:
<div id="divMain">
::after
</div>
And here's the CSS code:
#divMain:after { content: 'Back To Top'; position: relative; left: 93%; font-size: 16px; bottom: 30px; cursor: pointer; padding: 5px 10px; }
#divMain:after:hover { color: #b0f14f; }
For the JavaScript/jQuery part, I have this code:
$('#divMain:after').click(function () {
$('html, body').animate({ scrollTop: 0 }, 'fast');
});