JS报错Unexpected end of input

JS代码:

var city = document.getElementsByClassName("city-name");

var city_ico = document.getElementsByClassName("ico-city");

var city_list = document.getElementsByClassName("city-list")

//ico翻转

function ico_rotate(){

    var classVal = city_ico[0].getAttribute("class");

    var city_hover = document.getElementsByClassName("city-hover");

    //判断city是否存在

    if(city_hover.length !== 0){

        classVal = classVal.replace(" city-hover"," ");

        city_ico[0].setAttribute("class",classVal);

    }else{

        classVal = classVal.concat(" city-hover");

        city_ico[0].setAttribute("class",classVal);

    }

};

//显示隐藏

function toggle(className,num){

    var list = className[num].style.display;

    if(list == "block"){

        className[num].style.display = "none";

    }else{

        className[num].style.display = "block";

    }

city[0].addEventListener("mouseover",ico_rotate);

city[0].addEventListener("mouseout",ico_rotate);

city[0].addEventListener("mouseover",function(){

    toggle(city_list,0);}

);

city[0].addEventListener("mouseout",function(){

    toggle(city_list,0);}

);


maturity_process
浏览 14762回答 1
1回答

maturity_process

city[0].addEventListener("mouseover",ico_rotate);前没有大括号
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript