Issue with custom cursor not functioning properly when hovering over hyperlinks

I'm currently developing a website and I've created a custom cursor to replace the default one. The custom cursor is detecting mouse movement, but it's not interacting with hyperlinks. Below is the code I'm using.

HTML

<div class='cursor'></div>
<div class='cursor'></div>
<h1>Custom cursor</h1>
<a href="#">A link </a>

CSS

* {
  cursor: none;
}
.cursor {
  position: absolute;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  transform: translateX(-50%) translateY(-50%);
  z-index: 99999;
}
.cursor:nth-child(1) {
  background-color: #3A1C71;
  z-index: 999999;
}
.cursor:nth-child(2) {
  background-color: #FFAF7B;
}

JS

$(document)
  .mousemove(function(e) {
    $('.cursor')
      .eq(0)
      .css({
        left: e.pageX,
        top: e.pageY
      });
    setTimeout(function() {
      $('.cursor')
        .eq(1)
        .css({
          left: e.pageX,
          top: e.pageY
        });
    }, 100);
  })

Check out the Codepen Demo for reference

Your insights and assistance on this issue are highly appreciated

Thank you! :)

Answer №1

To avoid the manual process of creating a custom cursor, you can simply reference an image to use as a cursor in your CSS:

cursor: url('path-to-image.png'), auto; 

For more information, check out this resource: MDN reference


If you prefer to stick with your current solution:

The reason why the hyperlink is not responsive is that the two cursor divs are overlapping and blocking the link itself.

To solve this, you can disable mouse events for these divs so that the events pass through to the underlying element:

.cursor {
  pointer-events: none;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to modify the styles of nested Material UI components

I am currently customizing the styles of the card and cardContent components in material ui. I have implemented them within functional components and am facing an issue with overriding the root style of each component. Specifically, I am struggling to modi ...

`Error encountered in MVC FormsAuthentication post user login`

In my application, I have implemented a login method that successfully communicates with the database and sets the authCookie in version 4.5.1. [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel model) ...

Integrating Query String Parameters into GridView Item Templates

Within my gridview, I have a hyperlink located in the first column. When this hyperlink is clicked, the user is directed to Vendor.aspx. I now need to pass the consumer ID (from the clicked row) as a query string to Vendor.aspx. What is the most effective ...

Transfer information to a php file through ajax

I'm facing an issue with receiving data sent via AJAX in a PHP file. The AJAX request seems to be sending data successfully as I receive a success message, but the PHP page shows an error "Notice: Undefined index: ab". Below is my jQuery code for sen ...

Unusual shadow cast by the box's silhouette

I am currently facing an issue with a box and its shadow. When I close the box, a different shadow lingers behind. I have tried troubleshooting this problem but cannot pinpoint the source. I have included the relevant code files in the specified folders. I ...

Strategies for decreasing padding or margin in Bootstrap without removing it

I am currently facing a dilemma with the grid system. Although it is supposed to be easy, I am struggling at the moment. Let's consider that I need to correctly implement the Bootstrap grid for this example: https://i.stack.imgur.com/33vse.png Initi ...

Caching of audio files in React streaming is enabled

My dilemma lies in the fact that despite creating a new file in the back-end, the <PlaySound /> component continues to play the old sound file rather than the updated one. Although the sound file maintains the same name and path, its content differs. ...

How can you use JavaScript to create a JSON object using values from an HTML form textarea and then send

I need to create an HTML form that will send specific information in the Http-request body. { “info” : { “id” : “123” “text1” : <data from html text-box> } Therefore, my goal is to convert the provided data into a JavaScri ...

The jQuery functionality is not functioning properly within the aspx file

I came across some JavaScript code on stackoverflow that is not working in my own code, but strangely it works perfectly fine in the jsFiddle: https://jsfiddle.net/rxLg0bo4/9/ Here is how I am using inline jQuery in my code: <nav id="menu"> < ...

Trouble with linkage in jQuery for AJAX requests in an external .js document

My asp.net application has a master file that includes the jquery.js file. On another page that uses this master page, I have my own jquery code. I attempted to move this code to an external file and then include it in my .aspx file. While most functions ...

Displaying column values in Vuetify Table based on a condition

https://i.stack.imgur.com/wK9uU.png I'm working with a Vuetify table that has a column for URLs. I need to implement logic to display either the URL or the URL Group name based on properties in my rules array. If rules[i].urlGroup is not empty, then ...

The Javascript countdown feature may experience issues on Safari and IE browsers

Why does this function work in Chrome, but not on IE or Safari? function countdown(){ var dDay = new Date().getUTCDate() + 1; var dMonth = new Date().getUTCMonth() + 1; var dYear = new Date().getUTCFullYear(); var BigDay = new Date(dYear+ ...

Emptying the data of a form that has been submitted using Ajax

None of the similar questions really address the issue from my perspective. I am facing a challenge with a user registration form where I utilize .post for ajax handling. Below is the code snippet: $('#register_user_form').submit(function(){ ...

"Enhance Your HTA Webpage with a Hover Zoom Effect on CSS Tables

Greetings and thank you for taking the time to read my message. I am relatively new to this, so please bear with me if things seem a bit disorganized. I have constructed a table and am attempting to implement a hover effect to zoom in on a specific cell w ...

What is the best approach to transpiling TypeScript aliased paths to JavaScript?

I am currently facing an issue with my TypeScript project where I need to transpile it into executable JavaScript while using path aliases for my NPM package development. One specific scenario involves importing a method from the lib directory without spe ...

Creating functionality in Ionic to allow for the dynamic addition of buttons to the navigation bar

I have a navigation bar and I would like to include a save button on it for just one screen. After going through various blogs, I found that the general advice is to declare buttons in the view rather than accessing them in a controller. But still, isn&apo ...

Submitting a POST request using a Chrome Extension

I am in the process of developing a Chrome extension popup for logging into my server. The popup contains a simple form with fields for username, password, and a submit button. <form> <div class="form-group"> <label for="exampleInputE ...

Unlocking the Power of Localization: An Easy Guide to Accessing JavaScript Values

After utilizing the localization helper created by Matt Hawley, I found it to be incredibly effective. However, I am encountering an issue when attempting to retrieve the values in javascript/jQuery. For example, I am unable to fetch the resource text usi ...

AJAX request: No values are being returned by $_GET

After spending hours trying to figure this out... I've been working on using AJAX to grab values from a jQuery slider within an <input> tag. The AJAX request is not failing (see code below), and when I use console.log to check the variable I&ap ...

Execute an AJAX call to remove a comment

Having some trouble deleting a MySQL record using JavaScript. Here is the JavaScript function I am trying to use: function deletePost(id){ if(confirm('Are you sure?')){ $('#comment_'+id).hide(); http.open("get","/i ...