I have little experience in using the $.fn.extend jQuery function; The code below is not working and it would seem that it would work as I've copy pasted it from this StackOverflow answer (jQuery Toggle Text?) The below code is as simple as I can get where the second function is not working... JSFiddle (http://jsfiddle.net/qxcwo51n/16/) however in my working example on a private site the 'toggle_active_iot' works but the extended function doesn't
$.fn.extend({
toggleText: function(a, b) {
return this.text(this.text() == b ? a : b);
}
});
function toggle_active_iot(link) {
$('.iot-items').toggleClass('active');
$('.iot-products').toggleClass('active');
}
.iot-items,
.iot-products {
display: none;
}
.active {
display: block !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='col-md-12'>
<h3 style='background-color:#151515;color:white;padding:10px;margin:0px;'>
<i class="far fa-hdd"></i> Internet of Things
<button onClick="$(this).toggleText('Items','Products');toggle_active_iot(this);">Items</button>
</h3>
</div>
<div class='iot-items active'>
Test Items
</div>
<div class='iot-products'>
Test Products
</div>
on*event attibute the functions needs to be at global scope, so change the settings to place the JS just before</body>: jsfiddle.net/qxcwo51n/28. This is also why the snippet I added in to your question works. I would suggest you get rid of theonclickattribute and use proper unobtrusive event handlers, suich as jQuery'son()