Desperate late night coding before a submission.
I have two HTML objects with two separate class names that I'm looking to bind the same event with different actionlisteners.
<form class="form-wrapper cf" action ="">
<input id="searchInput" type="text" placeholder="Search for Sets or Cards" required>
<button class="searchButton" type="button">Search</button>
</form>
I've managed to handle the button on click, and after reading the documentation for "on" I see that you can bind multiple listeners to the same class. However I can't figure out if it's possible to do the keyup as well.
$(".searchButton").on("click" ,function(){
Desperate late night coding before a submission.
I have two HTML objects with two separate class names that I'm looking to bind the same event with different actionlisteners.
<form class="form-wrapper cf" action ="">
<input id="searchInput" type="text" placeholder="Search for Sets or Cards" required>
<button class="searchButton" type="button">Search</button>
</form>
I've managed to handle the button on click, and after reading the documentation for "on" I see that you can bind multiple listeners to the same class. However I can't figure out if it's possible to do the keyup as well.
$(".searchButton").on("click" ,function(){
Share
Improve this question
edited May 7, 2013 at 8:50
snowp
4911 gold badge6 silver badges22 bronze badges
asked May 7, 2013 at 8:46
user1870954user1870954
2073 silver badges14 bronze badges
3
-
5
.on('click keyup', funciton(){
– elclanrs Commented May 7, 2013 at 8:47 - Possible duplicate stackoverflow./questions/8608145/… – Mark Walters Commented May 7, 2013 at 8:48
- @MarkWalters: Question is reversed. I'm looking for two listeners, same event, different objects. He has multiple events, one object, same listener. Not quite it. – user1870954 Commented May 7, 2013 at 9:21
4 Answers
Reset to default 7Try this:
$('.searchButton, #searchInput').on('click keyup' ,function(){
Are you looking for something like this: jsfiddle link http://jsfiddle/XAGD9/2/
$(document).on("click keyup",".searchButton" ,function(){
You can do this:
$(".form-wrapper").on("click keyup", ".searchButton",function(){
// Your code here
});
try this :
$(".searchButton").bind("click keyup" ,function(){});