How to implement a custom cursor change on mousedown without relying on the mousemove event (using jQuery)

Adjusting Cursor Behavior

In my quest to create a draggable scrollable image, I am attempting to change the cursor over an image when a certain variable is set to zoom mode to enhance usability. However, I have encountered an issue where the cursor only changes after clicking the ".page" and then moving the mouse, rather than immediately upon clicking as expected. Below is an example of the code:

$(".page").on("mousedown", function (evt) {
    if(model.zoomMode){
        $('.page').css('cursor','url("img/hand_closed.gif"),auto');
    }       
}).on("mouseup", function (evt) {
    if(model.zoomMode){
        $('.page').css('cursor','url("img/hand_open.gif"),auto');
    }
});

Alternative CSS-Based Approach

A similar issue arises when using classes for the same purpose. For instance, adding a class outside of the .page object in zoom mode and utilizing the following JavaScript:

$(".page").on("mousedown", function (evt) {
    $('.page').addClass('mouseDown');
}).on("mouseup", function (evt) {
    $('.page').removeClass('mouseDown');
});

The corresponding CSS looks like this:

.zoom .page:hover{
    cursor:url(../img/hand_open.gif),auto;
}

.zoom .page.mouseDown:hover{
    cursor:url(../img/hand_closed.gif),auto;
}

I am currently testing in Chrome 18. Does anyone have a solution to apply the CSS cursor change without requiring mouse movement?

Answer №1

Simple answer: Negative.

Detailed answer: Regrettably, no.

(reference)

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

I'm looking for a Visual Studio add-in that can identify and flag any unused CSS classes or IDs within the entire solution

Exactly as the headline suggests. If not, what are some reliable online services you've tried for decluttering oversized stylesheets? ...

Tips for choosing certain viewports using media queries

I am attempting to target a specific range between 767px and 1024px. This should be applicable to the screen, as well as iPad portrait mode, but NOT for iPad in landscape mode. I have experimented with various queries, but none of them have yielded the d ...

Is it possible to reuse a variable within a single HTML tag when using Angular 2?

I encountered a strange issue with Angular 2 that may be a bug. I noticed that I couldn't print the same variable in a template twice within the same HTML tag. When I tried to use the following code, it resulted in error messages. <div class=" ...

Utilizing a box within a background image using HTML and CSS

In the midst of my college project, I've encountered a hurdle. There's an image I need to overlay with a box that has padding on all sides corresponding to the outline of the image. Despite my attempts, I haven't been successful in achieving ...

Using jQuery to change the color of a child element based on a data attribute

Can anyone suggest a solution for this issue? $("div[data-color]").each(function() { $(this).children('p').css('color', function () { return $(this).data('color') }); }); Here is the structure of the code: ...

Retrieve the HTML code stored as a string and showcase it within an Angular framework

I need assistance with extracting content from an email stored in a javascript/typescript string (message.body). The string contains HTML code like this: <div dir="ltr">test mail</div> Using angular bootstrap, I attempted the follow ...

`In Firefox, perspective can lead to unexpected overflow errors.`

Having difficulties setting up a parallax effect using CSS perspective and translateZ. Encountering strange overflow errors specifically in Firefox. Check out the issue here When moving the mouse around, noticing that the background-image is getting crop ...

Troubleshooting: jQuery AJAX failing to receive JSON data in HTTP request

Experimenting with HTML and jQuery to practice JSON requests, I conducted some research and attempted a small test. However, upon running the script in Google Chrome, only my HTML/CSS elements appeared instead of expected results. Below is the code snippet ...

Guide to opening all href links in a new window

When loading HTML content parsed from an email to a frame, the issue arises when there is an href link that tries to open in the same frame. I want to modify it so that it opens in a new tab instead. Usually, setting the target to _blank in the href would ...

Tips for repairing a button on an image backdrop and ensuring its position remains unchanged during resizing

My goal is to add tags to people's faces on my website. While I am aware of the image map property, I am facing an issue where the background of the main Div needs to be set to 'cover'. However, when the window is resized, the coordinates of ...

Show identification as an alternative term in the chart

Is there a way to display an id in a table cell as another name from a different object with corresponding ids? I want to achieve something like this if it's possible: <td class="tableRowText"><p>{{l.SenderId}}</p></td> simil ...

What is the reason for elements such as "if" and "else" not being visually

I am currently developing a browser-based code editor with a unique feature. Task: The objective is to highlight specific keywords like if, else, for... when they are entered into the editor. textarea.addEventListener("input", function() { ...

JavaScript validation for comparing date and time combinations

Alert needed for cases where the start date is earlier than the end date, using the format dd/mm/yyyy and 24-hour time :HH:MM:SS var strt_date = 31/03/2014 23:02:01; var end_date = 01/04/2014 05:02:05; if(Date.parse(strt_date) < Date.parse(end ...

Tips for effectively interpreting a json string

Trying to extract specific fields from a JSON string and display them on an HTML page, but encountering the following error: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data This is the JSON being sent: { "Order0& ...

Navigating the webpage filled with tabbed information

I'm encountering some laggy scrolling issues on my website, specifically within the tabbed gallery section that was created using jQuery. I've noticed that when I try to scroll while an image tab is active in the gallery, the scrolling performanc ...

Modifying SASS variable values based on the presence of specific text in the page URL

How can I utilize the same SASS file for two different websites with similar functionality but different color schemes? My goal is to dynamically change the color based on the URL of the page. However, I am facing challenges in extracting the page URL from ...

Creating vertical alignment in flexbox

How can I add a vertical line that extends between the sidebar and main content on my website? The border-right in my sidebar only goes partway down, and I need it to go all the way. Any help would be greatly appreciated! Link to code snippet ...

Display the images adjacent to the usernames, followed by their respective levels underneath

<div class="players"> {{#each users}} {{#each usersInLobby}} <img src="/img/characters/{{skin}}.png" style="height: 85px; display:inline;"> <p>{{username}}{{level}}</p> {{/each}} {{/each}} ...

What is the best way to incorporate functionalities for selecting all, deselecting all, and resetting all options within a checkbox list?

I recently undertook a tutorial challenge to create: Tick ALL boxes - Taco Everything Untick ALL boxes - Untaco Everything Delete ALL boxes - Eliminate all the 'dishes' in the menu added I am grappling with this. While my code successfully add ...

Using Jquery to alter elements during every iteration loop

With the help of jquery, my goal is to iterate through all elements that belong to the "item" class and give them different background colors based on their index position. The array mapcolor contains a variety of colors (with a length matching the number ...