开发者

selected link changes background

I have 2 menus, category and countries. I开发者_运维问答've made so far to change and keep background of one element but I have problem with simultaneous memory of other menu's element.

var lookaround=[];

function seleItem(obj,color){
    if(lookaround[obj.className])
        lookaround[obj.className].style.background=null;
    lookaround[obj.className]=obj;
    obj.style.background=color;
}

Example page is HERE


You should use an object instead of an array for lookaround:

var lookaround = {};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜