在Javascript中模拟单击/取消单击引导按钮
我有下面显示的按钮,当用户单击按钮时,所选按钮变为活动按钮,而上一个所选按钮变为非活动按钮(很像这个引导示例) HTML:在Javascript中模拟单击/取消单击引导按钮,javascript,html,button,bootstrap-4,Javascript,Html,Button,Bootstrap 4,我有下面显示的按钮,当用户单击按钮时,所选按钮变为活动按钮,而上一个所选按钮变为非活动按钮(很像这个引导示例) HTML: 经过再三考虑,我认为这将有助于明确我是如何导航到选项卡的——单击后,我将向settab()函数发送一个参数,并使用ng show=“currenttab==”\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu您是否尝试过模拟mouseup或mouseleave?请尝试docum
经过再三考虑,我认为这将有助于明确我是如何导航到选项卡的——单击后,我将向settab()函数发送一个参数,并使用
ng show=“currenttab==”\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu您是否尝试过模拟mouseup或mouseleave?请尝试document.getElementById(“第七个选项卡”)。单击()
-HTMLElement.click()是一个实际的函数,应该可以让您获得所需的内容need@TomášZato我没有试过-我会试试。@VirxEC我试过document.getElementById(“第七个选项卡”)。单击()
和document.getElementById(“第七个选项卡”).trigger('click)
-两者都不起作用:(将所有JavaScript包装在窗口中。onload=function(){/*code*/};
<div id='button-tabset'>
<uib-tabset>
<uib-tab index="0" heading="Tab1" class="exampletab"></uib-tab>
<uib-tab index="1" heading="Tab2" class="exampletab"></uib-tab>
<uib-tab index="2" heading="Tab3" class="exampletab"></uib-tab>
<uib-tab index="3" heading="Tab4" class="exampletab"></uib-tab>
<uib-tab index="4" heading="Tab5" class="exampletab"></uib-tab>
<uib-tab index="5" heading="Tab6" class="exampletab"></uib-tab>
<uib-tab index="6" heading="Tab7" class="exampletab" id="seventhtab"></uib-tab>
</uib-tabset>
</div>
$scope.exampleFunction = function() {
$scope.currenttab = 'tab7';
var header = document.getElementById("button-tabset");
var btns = header.getElementsByClassName("exampletab");
for (var i = 0; i < btns.length; i++) {
var current = document.getElementsByClassName("active");
if (current[0]) {
current[0].className = current[0].className.replace(" active", "");
}
}
document.getElementById("seventhtab").className += " active";
};
<div id='button-tabset'>
<uib-tabset>
<uib-tab index="0" heading="Tab1" select="settab('Tab1')" class="exampletab"></uib-tab>
<uib-tab index="1" heading="Tab2" select="settab('Tab2')" class="exampletab"></uib-tab>
<uib-tab index="2" heading="Tab3" select="settab('Tab3')" class="exampletab"></uib-tab>
<uib-tab index="3" heading="Tab4" select="settab('Tab4')" class="exampletab"></uib-tab>
<uib-tab index="4" heading="Tab5" select="settab('Tab5')" class="exampletab"></uib-tab>
<uib-tab index="5" heading="Tab6" select="settab('Tab6')" class="exampletab"></uib-tab>
<uib-tab index="6" heading="Tab7" select="settab('Tab7')" class="exampletab" id="seventhtab"></uib-tab>
</uib-tabset>