I need to change color of text under circle that follows mouse cursor.
I coded circle to follow cursor but I don't know how I can change color of text under the circle. I would like color to be changed to background color of header.
My code:
$(document).ready(function() {
var mouseX = 0,
mouseY = 0,
xp = 0,
yp = 0;
$("header").mousemove(function(e) {
mouseX = e.pageX - 30;
mouseY = e.pageY - 30;
xp += ((mouseX - xp)/6);
yp += ((mouseY - yp)/6);
$(".circle").css({
left: xp +'px',
top: yp +'px'
});
});
});
header {
background: #800000;
padding: 100px 20px;
position: relative;
overflow: hidden;
}
h1, p { color: #ffffff; }
.circle {
width: 100px;
height: 100px;
background: #ffffff;
border-radius: 50%;
position: absolute;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet illo, iure ipsa excepturi tempora nemo deleniti consequatur dolore dolorem qui.</p>
<span class="circle"></span>
</header>