some month ago i work to make a interactive web with javascript but when i copy the project to my patner which use Apple Mac Pro then the interactive is not active. So i use another try change

function showDiv(tahun){
    document.getElementById(tahun).style = "display:none;"; 


function showDiv(tahun){
    tahun.style.display = "block"; 

but it doesn't work...
so i write manual every div

<a onclick="showDiv2013_2014">Show</a>
function showDiv2013_2014(){
    tahun_2013_2014.style.display = "block";
function showDiv2014_2015(){
    tahun_2014_2015.style.display = "block";

The project was done but i want to know what the problem is...

2 Years
Discussion Span
Last Post by Troy III

Do you know what browser they were using? I highly doubt it is the operating system that doesn't handle the javascript correctly. I'm going to guess they were using Safari.
You could have tried jQuery instead too. That would have saved doing every div manually as you have done as you could have used jQuery selectors for the same effect.


Forget about the last two versions, I can already see that your problem in the first version is that you're not using quotes around your Id name. You absolutely must use single or double quotes around your id name or it will break your code. It should look like this:


I also see a couple other problems with your syntax. For one, to change the style of the element with id of "tahun" to a display of "none", you need to write it like this:

            document.getElementById("tahun").style.display = "none";

You have the CSS name and value paired up on the right side of the equal sign as though you were creating a style rule in a CSS document. That's one thing that killed your code.

Another potential problem I see is the argument in showDiv(tahun). Unless tahun is both an id in one of your elements, as well as a variable that you need to pass to something inside the showDiv() function, then don't use tahun as an argument. Instead, write it like this:

            function showDiv() {

            // Your code goes here.


Again, I don't know if you're using the name "tahun" both as an id and a variable name. If tahun is a variable name, you might need to keep it in the parentheses of your showDiv() function, but I would need to see all of your code to know that.

One last thing - if you are using tahun for both a variable name and an id name, change one of them. It's confusing for you and anyone else who has to read your code. And if you do change one of them to something else, make sure you change every instance of the one you decide to change throughout your entire code so you don't have inconsistencies which will break your code.

I hope this helps you. Good luck.


"oh my god" - where am I?!!
panjiasmara, you never told us how did you call the function "showDiv()" in your original script.

Please do, because if it worked on other systems we can make it work on apple too.


you are right it not an opration system error... i was develop it with mozilla firefox and not tested it with another browser that time. this is because my syntax error it not work on chrome too but it worked well in mozilla firefox...

document.getElementById("list_bogor_2014_2015").style = "display:none";
work well in mozilla but not in chrome and another one.

document.getElementById("list_bogor_2014_2015").style.display = "none";
work well in both mozilla and chrome...

thank you for answer my question

sorry for troublesome


This shouldn't have worked on either. It's a Mozilla faulty omission for allowing the add of arbirary style property names (and values) as strings [!!!]
document.getElementById("list_bogor_2014_2015").style = "display:none";

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.