Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger onclick without clicking

Tags:

html

jquery

I have created a news aggregator site which also measures the popularity of the posts. I have the HTML and jquery set up so that when you click the link it also counts the amount of clicks.

<a class="headline" href="www.example.com/a" target="_newWindow" onclick="incStoryClicksCount('15280681', '_on_click_handler');  return wopen('www.example.com/a');" rel="nofollow">Example A</a>

However i need to test to to see if it works, is there an easier way when viewing the site than to click multiple times to try and get the count up. I was thinking trying to trigger it so it counts as a click, in the chrome console (F12). However i don't know how i'd go about doing that.

An alternative i was thinking about was changing the code when pressing on f12 in chrome, so that instead of 'on click' it would be when i slightly moved my mouse or click a button. However i also don't really know how to execute this.

like image 563
Will Fisher Avatar asked Nov 19 '25 03:11

Will Fisher


1 Answers

You can use the .click() method of jQuery. For example

$('a.headline').click();

It will trigger the event

like image 157
prtdomingo Avatar answered Nov 20 '25 18:11

prtdomingo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!