当试图听取按键然后提交数据进行验证时,该值似乎是1个字符...
$(function () {
$('.entry').on('change keypress', function () {
alert($(this).val());
});
});
HTML
<tr>
<th>Name</th>
<td>
<input class='entry' type='text' id='name' name='name'>
</td>
答案 0 :(得分:4)
尝试使用$(".entry").on("input", function() {
alert($(this).val());
});
事件
input
jsfiddle http://jsfiddle.net/ba6688my/1/
答案 1 :(得分:3)
改为使用$(function(){
$('.entry').on('input',function(){
alert($(this).val());
});
});
事件:
- (void)scrollToBottomAnimated:(BOOL)animated
{
if ([self.collectionView numberOfSections] == 0) {
return;
}
NSInteger items = [self.collectionView numberOfItemsInSection:0];
if (items == 0) {
return;
}
CGFloat collectionViewContentHeight = [self.collectionView.collectionViewLayout collectionViewContentSize].height;
BOOL isContentTooSmall = (collectionViewContentHeight < CGRectGetHeight(self.collectionView.bounds));
if (isContentTooSmall) {
// workaround for the first few messages not scrolling
// when the collection view content size is too small, `scrollToItemAtIndexPath:` doesn't work properly
// this seems to be a UIKit bug, see #256 on GitHub
[self.collectionView scrollRectToVisible:CGRectMake(0.0, collectionViewContentHeight - 1.0f, 1.0f, 1.0f)
animated:animated];
return;
}
// workaround for really long messages not scrolling
// if last message is too long, use scroll position bottom for better appearance, else use top
// possibly a UIKit bug, see #480 on GitHub
NSUInteger finalRow = MAX(0, [self.collectionView numberOfItemsInSection:0] - 1);
NSIndexPath *finalIndexPath = [NSIndexPath indexPathForItem:finalRow inSection:0];
CGSize finalCellSize = [self.collectionView.collectionViewLayout sizeForItemAtIndexPath:finalIndexPath];
CGFloat maxHeightForVisibleMessage = CGRectGetHeight(self.collectionView.bounds) - self.collectionView.contentInset.top - CGRectGetHeight(self.inputToolbar.bounds);
UICollectionViewScrollPosition scrollPosition = (finalCellSize.height > maxHeightForVisibleMessage) ? UICollectionViewScrollPositionBottom : UICollectionViewScrollPositionTop;
[self.collectionView scrollToItemAtIndexPath:finalIndexPath
atScrollPosition:scrollPosition
animated:animated];
}