javascript - why click on div do not automatically click on tab -
i using mvc-5 , in view have number of divs arranged horizontally , below each divs have tabs. each div arranged such contains tabs below it.
now have ? have click on div , upon clicking div must automatically click tab below it.(i don't want manual )
my try :
i have created onclick event of div , have assigned id tab.
problem tab never clicked on clicing respectivce div.
my code is:
<div class="panel-body"> <div class="col-md-2" id="active" onclick="activecircleclick('tab1')"> <div id="active" style="height: 125px;"> //here </div> </div> </div> <div style="width:1300px;"> <div style="width:100%;"> <ul class="nav nav-tabs nav-pills nav-justified" role="tablist" id="mytab"> <li class="active" id="activelist"> <a href="#tab1" data-toggle="tab">active device list</a> <span class="col-md-12" id="activedevicestatus" style="text-align: center;"></span> </li> </ul> </div> <script> function activecircleclick(el) { alert("test1:" +el); selecttab(el); } function selecttab(tabid) { alert('test2:' + tabid); var tab = $("#" + tabid); if (typeof tab != 'undefined') { e.preventdefault() tab.tab('show'); } } </script>
my both alert message popups don't click tab below div have clicked.
how make happen ?
i soved issue doing this:
function activecircleclick(el) { $('#tab1').bind('click', function () { }); $('#tab1').trigger('click'); }
Comments
Post a Comment