【发布时间】:2017-09-18 09:42:20
【问题描述】:
我有下面的 jquery。一切正常,除了....如何在提交按钮之外获得点击以停止触发动画?
这是否与先点击输入框,然后添加值,然后点击是第二次变化有关?
<form action="" method="post">
<div id="<?php echo $this->item['id']; ?>">
<div class="ab">
<label for="ab_input"><?php echo $this->translate('To get the auction started, you must enter a starting bid.'); ?></label>
<span class="auction_bid_container">
<input id="ab_input" type="text" maxlength="12"
class="middle nmr event-clear-focus"
name="bidz" value="Enter something" />
<input id="updateBidButton" type="submit"
class="button grey-button num-items-button"
name="bidz"
value="<?php echo $this->translate('submit'); ?>"/>
</span>
</div>
</div>
</form>
<div class="clear mb20"></div>
$('input[name="bidz"]').live('change', function () {
var bidz = this.value;
$.ajax({
type: 'post',
url: "?module=is&controller=index&action=syy",
dataType: "text",
data: 'bid=' + bidz + '&id=' + id,
beforeSend: function () {
$('.ab').animate({
'backgroundColor': '#ffdead'
}, 400);
},
success: function (result) {
if (result == 'ok') {
console.log(bidz);
$('.ab').animate({
'backgroundColor': '#A3D1A3'
}, 300);
} else {
$('.ab').animate({
'backgroundColor': '#FFBFBF'
}, 300);
}
}
});
});
【问题讨论】:
-
你的html代码中
input[name="bid_amount"]在哪里,根据你的htmk你有input[name="bidz"] -
抱歉@SuperUser,我已将bid_amount 更改为bidz。
-
@ian 你的
jQuery是什么版本? -
@DavidR 这是一个旧版本 - 1.8.1。我需要更新,但没有意识到 b/c 有太多遗留代码。
标签: javascript jquery html jquery-animate inputbox