【发布时间】:2017-02-06 23:31:38
【问题描述】:
当用户更改输入 name="qty" 并在该元素上显示引导工具提示时,我需要找到最接近的元素 fa-retweet...
我尝试使用代码:
$('input[name=qty]').change(function() {
$(this).closest('.fa-retweet').tooltip('show');
});
但什么也没发生。请帮忙。
使用完整的 html 代码更新:
<form method="post" action="/updateCart/35c3d0bd350dba471e8270d0f61e559d" accept-charset="UTF-8">
<input name="_method" type="hidden" value="post">
<input type="hidden" name="_token" value="3r2qqrgYG62HVB5xkOOJYN5lVm5v4TNWK5ECQcoH">
<div class="col-md-1 col-xs-4" style="padding:0px; ">
<input class="margin-mobile" type="number" name="qty" id="qty" value="3" style="width:40px; height: 30px; margin-top:5px; text-align: center !important; border: 1px solid #cf931e; color: #cf931e;">
</div>
<div class="col-md-2 col-xs-4 text-right" style="padding:0px;">
<h2 class="text-theme" style="font-size:36px !important; margin-top:0px !important;">£96
<sup style="position: relative;vertical-align: baseline;line-height: 0;font-size: 14px;top: -1.2em;">
00 </sup> </h2>
</div>
<div class="col-md-2 col-xs-4 text-right" style="margin-top:5px;">
<h3 style="margin:0px !important;"><button type="submit" data-toggle="tooltip" title="Click here to change quantity!" class="text-theme btn-non"><i style="margin-right:-5px;" class="fa fa-retweet" aria-hidden="true"></i></button> | <a href="/remove/35c3d0bd350dba471e8270d0f61e559d" class="text-theme"><i class="fa fa-trash" aria-hidden="true"></i></a></h3>
</div>
</form>
【问题讨论】:
-
尝试将
qty放在引号中:$("input[name='qty']")。另外,您是否遇到任何错误? -
不,没有错误
-
完整代码在哪里?
-
我用完整代码更新
标签: jquery html twitter-bootstrap onchange closest