Try $('a#songid')[0].click()
instead.
So, get the first element, and call the click method instead of triggering the event.
Try $('a#songid')[0].click()
instead.
So, get the first element, and call the click method instead of triggering the event.
<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.
Thank you so much, it works.
Glad this works for you. Would be great if you could accept the answer 🙂