scarhand Posted November 11, 2008 Share Posted November 11, 2008 code: function loadnews() { document.getElementById('newshead').innerHTML = document.getElementById('newshead1').innerHTML; document.getElementById('newstext').innerHTML = document.getElementById('newstext1').innerHTML; document.getElementById('newsheadsub').innerHTML = document.getElementById('newshead2').innerHTML; } function swapnews() { if (document.getElementById('newshead').innerHTML = document.getElementById('newshead1').innerHTML) { document.getElementById('newshead').innerHTML = document.getElementById('newshead2').innerHTML; document.getElementById('newstext').innerHTML = document.getElementById('newstext2').innerHTML; document.getElementById('newsheadsub').innerHTML = document.getElementById('newshead1').innerHTML; } else { document.getElementById('newshead').innerHTML = document.getElementById('newshead1').innerHTML; document.getElementById('newstext').innerHTML = document.getElementById('newstext1').innerHTML; document.getElementById('newsheadsub').innerHTML = document.getElementById('newshead2').innerHTML; } } the body onload calls the "loadnews" function im trying to get it so that they can swap back and forth whenever the person clicks on the link containing the "swapnews" function so far it will only swap once, and wont swap back Quote Link to comment Share on other sites More sharing options...
webster08 Posted November 11, 2008 Share Posted November 11, 2008 you need to change the onclick event for your link; once the function is executes. something like this: if (whatever.........) { document.getElementById("mylink").onclick = function() { // add function here } } or you can used DOM to set a listener - either/or.........; would work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.