473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Jquery mousedown button

Jezternz
145 100+
So I want to create a button, that changes its background image when the user presses down on it. My button is a division. Now I could simply use mousedown() and mouseup(), however there are many problems that can arise from this. For example a user could push the mouse down then move the mouse off the button. The user could also press alt-tab or something after mousing down. Either of these events would cause the button to stay pressed down even though the user has mouseup'ed. I could find a bunch of ways to overcome this stuff, however I was rather hoping Jquery may already have the functionality there. Here is my simple code:
Expand|Select|Wrap|Line Numbers
  1. $("#loginButton")
  2.     .mousedown(function(){$(this).addClass("menuButtonDown")})
  3.     .mouseup(function(){$(this).removeClass("menuButtonDown")});
  4.  
(where #login is the button)

Cheers, J
Aug 23 '10 #1

✓ answered by Oralloy

You might want to ask the jQuery developers to add the feature. They seem to be good hearted folks.

In the meanwhile, try trapping mouseup and blurr to restore the base image. Also, focus has to handle entry with the mouse already down. It shouldn't be too difficult, I think.

2 2219
Oralloy
988 Expert 512MB
You might want to ask the jQuery developers to add the feature. They seem to be good hearted folks.

In the meanwhile, try trapping mouseup and blurr to restore the base image. Also, focus has to handle entry with the mouse already down. It shouldn't be too difficult, I think.
Aug 23 '10 #2
Jezternz
145 100+
Okay, Cheers, will give that a go!
Aug 24 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Colin McGuire | last post by:
Hi again, thanks everyone for your previous help. But having resolved past problems, I'm moving on to new problems :( This one is a simple winforms application with two buttons, named Button1...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
0
by: Chas Large | last post by:
Hi All, I have written a small program which has command buttons to operate a device by remote via RS232. It sends a series of commands when a command button is clicked and held down and stops...
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
3
by: Reveller | last post by:
I'm rewriting my own js library to jquery functions. A huge undertaking, but hopefully worth it in the future :) Question: why does the script always return 0 for img_width? Logo.gif exists and...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: amskape | last post by:
hi Friends, I need to Upload some files in a Listing , by clicking corresponding Upload link, then a popup window will come with Browse option as Shown in attachment File. My actual need is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.