Reputation: 1060
I'm trying to select all of the text in a textbox when the user sets focus to it. I only want to do this for specific textboxes, and using the class assigned to them seems to be the simplest way. Currently I'm using:
$("input[type='text']").click(function () {
$(this).select();
});
which works on all textboxes but I can't figure out how to modify it to do the select only if the textbox has the class 'positionField' assigned to it.
Upvotes: 0
Views: 62
Reputation: 1670
I believe what you are looking for is the following:
$("input[type='text'].positionField").click(function () {
$(this).select();
}
Upvotes: 1
Reputation: 10765
use the period to signify class in a Jquery selector:
$(".yourClassName").click(function () {
$(this).select();
});
Upvotes: 1