I have a HTML anchor that when clicked should make a div slide up or down (I call JQuery’s .slideToggle(); function);
My Problem: When I click the link, instead of executing code, it goes to a new page, where the url is the javascript code, in my case, “javascript: $('#attachFileContainer').slideToggle();” and the contents of the page(body) is simply “[object Object]“.
My Code:
<a class="interactiveLink"
href="javascript: $('#attachFileContainer').slideToggle();">Attach File</a>
What is going wrong, I have had many anchor elements where I call javascript from the href attribute and this have never happened?
You want this:
The
return falseprevents the link from doing anything after theonclickstuff runs.