0

 <a href="javascript:firescript('1','2','3');" id="songid" class="track__number">

This is the anchor tag. Now to automate click on this anchor tag to execute the href --> javascript fn using jquery

     $(document).ready(function () {
          $('a#songid').trigger('click');
        });

This doesn't seem to execute the JavaScript function. Please help me regarding this.

NOTE: The function is an AJAX query so i wouldn't want to redirect to some other page.

  • Use `$('a#songid')[0].click();` (I assume jQuery only triggers event listeners assigned by jQuery) –  Jun 15 '20 at 15:06

1 Answers1

0

Try $('a#songid')[0].click() instead.

So, get the first element, and call the click method instead of triggering the event.

Lennart Steinke
  • 584
  • 5
  • 11