Targeting tab content

Ok, you haven’t added id=“product-nav” to the dropdown and there was a typo on this line.

var $el = $(event.target).closest(a);

Use this script instead.

<script>
    $('#product-nav').on('click', 'a', function(event) {
          event.preventDefault();

          var $el = $(event.target).closest('a');
          var hash = $el.attr('href').split('#')[1];
          $('a[href="#' + hash + '"]').tab('show');
        })
</script>

These sections were only for explaining how the script worked, they don’t need to be included.

$('a[href="#minisonic"]').tab('show')
$('a[href="#sonictravel"]').tab('show')
1 Like