Solved

jQuery: Fire only once with multiple binds

Posted on 2012-03-28
4
428 Views
Last Modified: 2012-04-15
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
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 400 total points
ID: 37777391
use this:-
$('.xyz input').click(function(){
  alert('Hello');
 });

Open in new window

0
 
LVL 42

Expert Comment

by:David S.
ID: 37778635
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
 
LVL 16

Author Comment

by:hankknight
ID: 37779687
Will click fire even if the radio is changed by the keyboard?
0
 
LVL 42

Accepted Solution

by:
David S. earned 100 total points
ID: 37779782
Yes, the click event will fire even if the keyboard is used to select the radio button instead of the mouse.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question