This is my JavaScript function:
function switch_div(firstID,secondID) {
if((document.getElementById(firstID).style.display == 'inline') &&
(document.getElementById(secondID).style.display == 'inline')) {
document.getElementById(firstID).style.display = 'none';
} else if(document.getElementById(firstID).style.display == 'inline'){
document.getElementById(firstID).style.display = 'none';
document.getElementById(secondID).style.display = 'inline';
} else if (document.getElementById(firstID).style.display == 'none') {
document.getElementById(firstID).style.display = 'inline';
document.getElementById(secondID).style.display = 'none';
}
}
And this is my link and the two s I want to switch between them by clicking the same link each time:
<a href="#" onclick="switch_div('first_choice','second_choice');return false" style="position:relative">
<div id="first_choice" style="position:relative;">hello</div>
<div id="second_choice" style="position:relative;">bye</div>
This link to the JavaScript function works fine in Opera but not at all in Firefox. Why is that the case?