I know this is probably a simple problem, but I cannot find anything about it. I have the following code:
var moreitemsdiv = $('.moreitemsdiv');
$('.moreitemsanchor').bind("focus click", function(){
showList(this);
return false
});
function showList(this_anchor){
var thismoreitemsdiv = $(this_anchor).next(moreitemsdiv);
if ($(thismoreitemsdiv).hasClass('focus')) {
$(thismoreitemsdiv).removeClass('focus');
} else {
$(moreitemsdiv).removeClass('focus');
$(thismoreitemsdiv).addClass('focus');
}
};
The "focus" class is added to the click, but as the click is also the focus, it then removes it when it starts the function again. Do I need to untie and then bind again or something else?
Any help would be great, cheers!
source
share