View Full Version : changing style with Javascript (resolved)

09-22-2005, 07:18 AM
I'm trying to have an onClick event change the css properties of another element on my page.

In my CSS i have declared

div#extra {
visibility: hidden;

function showAdvanced()

is my function, I'm not sure if its right, I don't much experience with DOM, especially getElementById();

I have a sneaking suspicion the function isn't even being called though.

I call to it here:

<a href="" id="showAdvanced" onclick="showAdvanced();">Advanced &raquo;</a>

The problem is, when I click it, nothing happens.
Can you see the problem, or do you need more code?


09-22-2005, 07:50 AM
<a href="" id="showAdvanced" onclick="showAdvanced();return false">Advanced &raquo;</a>

09-22-2005, 07:55 AM
That didn't fix it, unfortunately. Though I figure it IS something as simple as that.


Okay, I figured it out. (Though, I prob. needed the return false as well.)

I had <script type="javascript">
instead of language="javascript"

to much CSS (type="text/css")

Thanks for you help, Paul

09-22-2005, 07:59 AM
The only real problem I saw was the return false which is good when you don't want the href to be activated. Because you had type="javascript" okay yes thats a problem. It should be type="text/javascript". language="javascript" is deprecated and shouldn't be used. The type declaration however should be used as it is required in order to validate.

09-22-2005, 08:10 AM
Excellent. Thank you.