I am currently trying to make an html link that will add elements (specifically, drop down menus) to the current page when you click it. Since I am adding all the elements to the page using JavaScript, I'm not sure how to set up the link to call a function rather than go to a different page. I've seen people set the href attribute to the function they want, so I tried that and it didn't work. I've also seen a way that involves using onclick and making the link follow the onclick, not go to a different page.
In summary, how do you create/edit a link (from javascript) to make it use a javascript function rather than go to a different page?
This is what I have currently (that concerns the link):
var link = document.createElement('a');
eval("link.setAttribute('href', 'javascript:addHours(" + dayDiv + ")');");