keyup events using class instead of id

jquery, jquery-selectors

Solution

$('.mytextbox').keyup(function(event){
 // play with event
 // use $(this) to determine which element triggers this event
});

Problem

If I have 2 textboxes, without using id's, how do I determine which textbox is firing off "keyup" events? For various reasons I need to use classes instead of id's, where the class name is the same for both textboxes. Infact, I could have the same textbox on the screen many times with the same class name. The HTML looks something like this ``` <div class="outer_div"> <input type="text" class="mytextbox" /> <div class="inner_div"></div> </div> <div class="outer_div"> <input type="text" class="mytextbox" /> <div class="inner_div"></div> </div> <div class="outer_div"> <input type="text" class="mytextbox" /> <div class="inner_div"></div> </div> ```

Original source