I don´t work much with javascript and I googled a lot the last few hours to figure out my problem. I guess I just don´t know the right words to search for.
This is what I want to achieve. A list of Links with a small arrow next to it. When you click on a link, a hidden div is shown and the arrow should move down to show that the text is "open". When I click on another text, the arrow should move up again and the div should be hidden. The other div would open accordingly. But the code is still a bit buggy. When I click on a link it gets the class "expanded" - but this class is not being automatically removed when I click on another item.
Here is my code so far... It doesnt work at all on jsfiddle, don´t know why http://jsfiddle.net/DvH75/
var _hidediv = null
function showdiv(id) {
if(_hidediv)
_hidediv();
var div = document.getElementById(id);
div.style.display = 'block';
$(".toggle").on("click", function(){
$(this).toggleClass("expanded");
});
_hidediv = function () { div.style.display = 'none'; };
}
And this is an example of what I want to archieve. The only difference is that I want an open item to close once another is opened: https://www.facebook.com/help/473865172623776/
I hope you understand my question and can help me Thank you very much!!