gpt4 book ai didi

jquery - Selectpicker( Bootstrap 选择)取消焦点更改

转载 作者:行者123 更新时间:2023-12-01 03:33:46 25 4
gpt4 key购买 nike

我正在使用隐藏的 anchor 来取消对更改的 Bootstrap 选择,如下所示:

HTML:

<select id="SelectAddress" name="SelectAddress" class="selectpicker" title="Select an address" data-header="Select an address">
<option id="1" value="1" selected >First address</option>
<option id="2" value="2" >Second address</option>
</select>

jQuery:

$("#SelectAddress").on("change", function() {
//...mycode...
$("#AFocus").focus();
});

$("#AFocus").focus(); 使选择选择器失去焦点,但它也使目标页面上升。 AFocus 位于页面顶部,所以...

如何在不使用像我的 AFocus 这样的 anchor 标记且不滚动页面的情况下取消选择选择器的焦点?

这是一个示例:http://jsfiddle.net/ya0o7hzb/向下滚动页面以查看 Bootstrap 选择。

最佳答案

bootstrap-select 将在 DOM 中添加一些 HTML,如下所示:

<div class="btn-group bootstrap-select"><button type="button" class="btn dropdown-toggle btn-default" data-toggle="dropdown" role="button" data-id="SelectAddress" title="Address 1" aria-expanded="false"><span class="filter-option pull-left">Address 1</span>&nbsp;<span class="bs-caret"><span class="caret"></span></span></button><div class="dropdown-menu open" role="combobox" style="padding-top: 0px; max-height: 297px; overflow: hidden; min-height: 37px;"><div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>Select an address</div><ul class="dropdown-menu inner" role="listbox" aria-expanded="false" style="max-height: 248px; overflow-y: auto; min-height: 0px;"><li data-original-index="1" class="selected"><a tabindex="0" class="" data-tokens="null" role="option" aria-disabled="false" aria-selected="true"><span class="text">Address 1</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="2" class=""><a tabindex="0" class="" data-tokens="null" role="option" aria-disabled="false" aria-selected="false"><span class="text">Address 2</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li></ul></div><select id="SelectAddress" name="SelectAddress" class="selectpicker" title="Select an address" data-header="Select an address" onchange="blur_picker('SelectAddress')" tabindex="-98"><option class="bs-title-option" value="">Select an address</option>

所以你必须blur()包含类btn的按钮:

$(".btn").blur();

工作示例:http://jsfiddle.net/93ohvn0j/

关于jquery - Selectpicker( Bootstrap 选择)取消焦点更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42158805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com