Trigger .slideUp at anchor

I’m trying to trigger an element to slide up when I reach an anchor. The anchor ID is #blacksection and the element class is .vc_tta-panels-container. I read on another thread that you can trigger onclick actions using something like:

jQuery("#blacksection").trigger('click');

And then I’m using;

  jQuery("#blacksection").on('click', function() {
    jQuery(".vc_tta-panels-container").slideUp();

as the remaining JS. So I have this:


jQuery("#blacksection").trigger('click');
  jQuery("#blacksection").on('click', function() {
    jQuery(".vc_tta-panels-container").slideUp();
});

Which isn’t working, only just started learning JS and it’s baffling my mind, can anyone shed some light on triggering .slideUp for a class at an anchor?


Source: stackoverflow-javascript

Anchor Tag’s On Click Event is Firing, but Default is not

I have an anchor tag wrapped around a radio input. When I click on them, the radio button gets checked, but the anchor tag does not do anything.

<a href="https://stackoverflow.com">
  <input type="radio" />
</a>

I tried adding an onclick handler to the anchor tag to see if it was being clicked and it worked as expected:

<a onclick="console.log('anchor clicked');" href="https://stackoverflow.com">
  <input type="radio" />
</a>

This also showed me that the anchor tag was being clicked twice so I added event.stopPropagation to the input tag:

<a onclick="console.log('anchor clicked');" href="https://stackoverflow.com">
  <input onclick="event.stopPropagation();" type="radio" />
</a>


Source: stackoverflow-javascript