0
<a href="#addnotes" onclick="javascript:submitAddNotes();">

How would i submit js simulated click on this ?

2
  • Can't you just run submitAddNotes()? Without simulating a click Commented Nov 9, 2015 at 21:02
  • FYI, don't prefix inline event handlers with javascript:. It has no use whatsoever. You could also write onclick="asdkjfhakjhkja:submitAddNotes();" and it would have the same effect. Commented Nov 9, 2015 at 21:05

1 Answer 1

6

Like this:

var anchor= document.querySelector('a[href="#addnotes"');
anchor.click();
Sign up to request clarification or add additional context in comments.

4 Comments

Cannot read property 'click' of null
Is your JavaScript in the same file as your HTML or a separate file?
chrome extension scripts.js
I'm not familiar with Chrome extensions, but you might resolve it by putting it within a DOMContentLoaded event. See developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.