【发布时间】:2021-12-23 16:26:38
【问题描述】:
我有两个不同的文本框(来自循环)。现在数据正在通过“点击”事件提交。但现在我也想在“输入”按钮之后“发布”数据(例如 facebook cmets)。我该怎么做?
这是我的代码
foreach ...
{
<!-- First text box -->
<input type="text" placeholder="Post your comment here" id="txt'.$FeedId.'" class="feed_in_input" name="">
<img class="feed_reply_smiley2" data-coin='.$CoinId.' data-max2='.$postID.' data-min2='.$postID.' data-stat='.$PostStatus.' id="button'.$FeedId.'" src="'.base_url().'/assets/social/images/feed_reply_smiley.svg" alt="img">
<!-- Second text box -->
<input type="text" placeholder="Reply to '.$UserName.'" id="txt'.$FeedId.'" class="feed_in_input" name="">
<img class="feed_reply_smiley" id="button'.$FeedId.'" src="'.base_url().'/assets/social/images/feed_reply_smiley.svg" alt="img">
}
这是我的脚本
$('.feed_reply_smiley2').unbind().click(function(e) {
//our code here
});
$('.feed_reply_smiley').unbind().click(function(e) {
//our code here
});
我只想每当用户按下“输入”按钮到任何文本框时,函数应该像处理“点击”事件一样执行。我该怎么做?
【问题讨论】:
-
这能回答你的问题吗? Detect the Enter key in a text input field
-
@bossxzero: 不,因为我被 php 中的循环卡住了
标签: javascript jquery