JQuery onchange in tabs event
jQuery ui ???
$("#tabs").tabs({
select: function(event, ui) {
alert("PRESSED TAB!");
}
});
$(function() {
$( "#tabs" ).tabs({ activate: function(event ,ui){
//console.log(event);
//alert( ui.newTab.index());
alert( ui.newTab.attr('li',"innerHTML")[0].getElementsByTagName("a")[0].innerHTML);
//alert( this.text);
} });
My Solution is Click Event Listener.
Solution:
$('.nav-tabs li').click(function () {
alert('Tab Clicked');
});
Complete Solution with HTML.
HTML
<div id="tabs">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<li><a data-toggle="tab" href="#menu1">Menu 1</a></li>
<li><a data-toggle="tab" href="#menu2">Menu 2</a></li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Some content.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Menu 1</h3>
<p>Some content in menu 1.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Menu 2</h3>
<p>Some content in menu 2.</p>
</div>
</div>
</div>
Script
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$('.nav-tabs li').click(function () {
alert('Tab Clicked');
});
Work for me
HTML:
<div id="tabs">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<li><a data-toggle="tab" href="#menu1">Menu 1</a></li>
<li><a data-toggle="tab" href="#menu2">Menu 2</a></li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Some content.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Menu 1</h3>
<p>Some content in menu 1.</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Menu 2</h3>
<p>Some content in menu 2.</p>
</div>
</div>
</div>
Script
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$("#tabs").tabs({
activate: function(event, ui) {
alert("PRESSED TAB!");
}
});
</script>