Bind Event To Textbox
What I show here is how in jQuery, to select all the textboxes in a certain area of the page such as in a div which has a class, and then assign a handler to an event for those elements. In the event I want to apply a jquery call to that particular textbox for which the event has fired.
So in this example I use jQuery to find elements which have a class name of 'classname', and then just to target the textboxes, (input[type=text]). With these elements I call .bind to bind a handler to the event 'click'. I create a handler which is passed a parameter called event, which can be used to target the actual textbox for which the event fired from. From that particular textbox I call removeClass, to remove the class called 'StyleTobeRemoved' which was attached to the textbox.
$('.className input[type=text]').bind("click", function(event) {
$(event.target).removeClass("StyleTobeRemoved");
});
....
<div class="className">
<input type="text" ...
</div>
Situations where this might be useful include validation, when the textbox gets focus you can change the style.