0

I was about to change the color of my links, that toggle some content with data-toggle="collapse", but it seems like the jQuery does not working properly.

jQuery:

$('#collapse_basic').on('show.bs.collapse', function () {
$('#toggle_basic').css('color', '#856404 !important');
});

Trigger:

<a class="p-2 text-muted" data-toggle="collapse" href="#collapse_basic" id="toggle_basic"><i class="fas fa-book"></i>&nbsp;Basic</a>

Content:

 <div class="collapse" id="collapse_basic">
    <main role="main" class="container">
      <p>...</p>
    </main>
</div>

I've also tried to change the $("#collapse_basic").on... to $("#toggle_basic").on... But nothing happens. Did i miss someting?

Best Regards

Tony Caterev
  • 127
  • 1
  • 2
  • 13
  • 1
    You never close your second ( and you never close { – xmaster May 07 '19 at 11:25
  • There seems to be a lot of code missing. You at least need to post the rest of the JS block so we can debug properly. – Doug F May 07 '19 at 12:20
  • @xmastertje pardon, its my first post, had some trouble with the post form. I've updated the jQuery line. Thanks for the support, Best – Tony Caterev May 07 '19 at 12:28
  • @DougF Thats all what i can post according to this problem. If it would help, i can post the rest of the html container as well. – Tony Caterev May 07 '19 at 12:29
  • No I have enough here to debug. It seems it's a problem with jquery not understanding how to apply important. Check out the issue at https://stackoverflow.com/questions/2655925/how-to-apply-important-using-css. If you take away the important and just use $('#toggle_basic').css('color', '#856404'); it does work. – Doug F May 07 '19 at 13:01
  • @DougF worked perfectly, thanks! – Tony Caterev May 07 '19 at 13:37

0 Answers0