In a .net aspx-Page, I have a gridview with textboxes for prices. There is a default price and other prices. I want to achieve the following: when field with default price loses focus, this price is written to all other price fields of the row. Additionally, the next price field of the row is selected (like it is when using the tab button).
My jQuery code (I use css-classes to get textboxes)
$('.defaultPrice').blur(function() {
var value = $(this).val();
开发者_运维知识库 if (value != "") {
$(this).closest('tr').find('.price').val(value);
}
$(this).closest('tr').find('.price').select();
});
Without the last line of the code, the next field is not selected. The script is not correct, because the next field is not selected (but the last).
Are you looking for this?
$('.defaultPrice').blur(function() {
var value = $(this).val();
if (value != "") {
$(this).closest('tr').find('.price').val(value);
}
$(this).closest('td').next().find('.price').select();
});
精彩评论