Hi, I am searching for an answer to a similar problem to Javascript not Working Correctly with OnClick and HREF. I have very simple javascript code but the onclick function is never called.
In the header of my index.html I have
Then, in the body, I have this:Code:<head> <script type="text/javascript"> function togglehide(var ID) { var item = document.getElementById(ID); if (item) { item.className=(item.className=='invisible')?'shown':'invisible'; } } function article_more(var bodyId, var moreId, var lessId) { togglehide(bodyId); togglehide(moreId); togglehide(lessId); document.write("<br/>THIS IS A TEST.. DEBUG FUNCTION 1 A 3<br/>"); } </script></head>
and my css definitions areCode:<div class='shown' id='cat1top1art2more'> <a href='#' onclick='article_more( cat1top1art2, cat1top1art2more, cat1top1art2less );return false;'>(more...)</a> </div> <div class='invisible' id='cat1top1art2less'> <a href='#' onclick='article_more( cat1top1art2, cat1top1art2more, cat1top1art2less );return false;'>(...less)</a> </div> <div class='invisible' id='cat1top1art2'> <p> block of text </p> </div>
My "(more...)" is displayed, but when I click on it, nothing happens. As you can see, I added a document.write() call to my function just to see if it ever goes there but that text is never written out.Code:.invisible { visibility: hidden; } .shown { visibility: visible; }
I am completely baffled by this. I am not sure why the onclick function is never called.




Reply With Quote