How to fix the code of the tabs?

People tell me how to solve it,there is code of tabs.When I add 1 tab it works,and when it works only 2 second even when you click on first.Pliz help,this is urgent.
(function($){ 
 jQuery.fn.lightTabs = function(options){

 var createTabs = function(){
 tabs = this;
 i = 0;

 showPage = function(i){
$(tabs).children("div").children("div").hide();
$(tabs).children("div").children("div").eq(i).show();
$(tabs).children("ul").children("li").removeClass("active");
$(tabs).children("ul").children("li").eq(i).addClass("active");
}

 showPage(0); 

 $(tabs).children("ul").children("li").each(function(index, element){
 $(element).attr("data-page", i);
 i++; 
});

$(tabs).children("ul").children("li").click(function(){
showPage(parseInt($(this).attr("data-page")));
 }); 
 }; 
 return this.each(createTabs);
 }; 
})(jQuery);
$(document).ready(function(){
$(".tabs").lightTabs();
});
March 23rd 20 at 19:09
1 answer
March 23rd 20 at 19:11
Check the HTML structure. Apparently you have one
is inside the other.
This code is working quite correctly:
<html>
the <head>
<script src='https://code.jquery.com/jquery-3.4.1.js'></script>
</head>
the <body>
<div class='tabs'>
the <ul><li>Tab1</li><li>Tab2</li></ul>
the <div><div style='display:none;'>1111</div><div style='display:none;'>2222</div></div>
</div>

<script type='text/javascript'><!--
(function($){ 
 jQuery.fn.lightTabs = function(options){

 var createTabs = function(){
 tabs = this;
 i = 0;

 showPage = function(i){
$(tabs).children("div").children("div").hide();
$(tabs).children("div").children("div").eq(i).show();
$(tabs).children("ul").children("li").removeClass("active");
$(tabs).children("ul").children("li").eq(i).addClass("active");
}

 showPage(0); 

 $(tabs).children("ul").children("li").each(function(index, element){
 $(element).attr("data-page", i);
 i++; 
});

$(tabs).children("ul").children("li").click(function(){
showPage(parseInt($(this).attr("data-page")));
 }); 
 }; 
 return this.each(createTabs);
 }; 
})(jQuery);
$(document).ready(function(){
$(".tabs").lightTabs();
});
//--></script>
</body>
</html>

Find more questions by tags HTMLjQueryCSS