• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

jQuery: Fire only once with multiple binds

This fires twice if I click on my radio button:

 $('.xyz input').bind('change click', function(){
  alert('Hello');
 });

Open in new window


How can I get it to fire only once, either if is clicked on or changed?
0
hankknight
Asked:
hankknight
  • 2
2 Solutions
 
BuggyCoderCommented:
use this:-
$('.xyz input').click(function(){
  alert('Hello');
 });

Open in new window

0
 
David S.Commented:
I agree with BuggyCoder.  The change event is only triggered on radio buttons in IE (or at least some versions of it) after the radio button loses focus, so it's best to just use the click event.
0
 
hankknightAuthor Commented:
Will click fire even if the radio is changed by the keyboard?
0
 
David S.Commented:
Yes, the click event will fire even if the keyboard is used to select the radio button instead of the mouse.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now