Liyakhat Ali Sheikh
Liyakhat Ali Sheikh

Reputation: 163

Property 'tab' does not exist on type 'JQuery'

My Html Code is

<nav class="nav-sidebar">
<ul class="nav tabs" id="myTab">
  <li class="active" ><a  href="#tab3" data-toggle="tab" >Tabl 1</a> </li>                               
  <li class="tab2"><a href="#tab2" data-toggle="tab">Tab 2</a></li>
  <li ><a href="#tab3" data-toggle="tab">Tab 3</a></li>
  <li ><a href="#tab4" data-toggle="tab">Tab 4</a></li>
  <li><a href="#tab5" data-toggle="tab">Tab 5</a></li>
</ul>

And in My .ts

$('#myTab a').click(function(e) {
     e.preventDefault();
     $(this).tab('show');
   });
   $("ul.nav-tabs > li > a").on("shown.bs.tab", function(e) {
     var id = $(e.target).attr("href").substr(1);
     window.location.hash = id;
   });
   var hash = window.location.hash;
   $('#myTab a[href="' + hash + '"]').tab('show');

Tried so many from stackoverflow and other web sites but i ended up with 'tab' doesn't exist in jquery

Upvotes: 2

Views: 3424

Answers (3)

Alik Rakhmonov
Alik Rakhmonov

Reputation: 121

You need to install @types/bootstrap.

Upvotes: 5

alalalala
alalalala

Reputation: 889

jQuery does not have a function tab();

Maybe you should import a Expansion witch add a function tab() into jQuery!

And if you us UI framework, you need to introduce the corresponding resources!

Upvotes: 0

Nir Tzezana
Nir Tzezana

Reputation: 2342

Seems like you're confusing tab() with tabs().
Read more here: http://api.jqueryui.com/tabs/

Upvotes: 0

Related Questions