I have 3 anchor (a) tags, all sharing a single div element to act upon. See my html below. Basically, when you click on anchor tag 1, I want it to fill the div with id="fillDiv" with html. When you click the second anchor tag, it should wipe that #fillDiv and replace it with new html. How do I set up such a functions. Here is my attempt
HTML:
js:
can anyone help?
HTML:
Code:
<div> <a id="a1" href="javascript: changeDiv();">tag1</a> <a id="a2" href="javascript: changeDiv();">tag2</a> <a id="a3" href="javascript: changeDiv();">tag3</a> </div> <div id="fillDiv"></div>
Code:
function changeDiv(){
if changeDiv().is('#a1'){
document.getElementById('fillDiv').html('<div>filling 1</div>');
}
elseif
changeDiv().is('#a2'){
document.getElementById('fillDiv').html('<div>filling 2</div>');
}
elseif
changeDiv().is('#a3'){
document.getElementById('fillDiv').html('<div>filling 3</div>');
}
}
Comment