Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当用户在地图上选择新图片时,我需要删除当前图片_Javascript_Html_Css - Fatal编程技术网

Javascript 当用户在地图上选择新图片时,我需要删除当前图片

Javascript 当用户在地图上选择新图片时,我需要删除当前图片,javascript,html,css,Javascript,Html,Css,}) $.select\u picture.changefunction{var value;x=document.getElementByIdchoice.value;//获取选择选项的值将其存储在x switchx中{case'0'://为我的语句value=0分配一个case和值;//alertvalue;break;case'1':value=1;//alertvalue;break;case'2':value=2;//alertvalue;break;default:value=nul

})

$.select\u picture.changefunction{var value;x=document.getElementByIdchoice.value;//获取选择选项的值将其存储在x switchx中{case'0'://为我的语句value=0分配一个case和值;//alertvalue;break;case'1':value=1;//alertvalue;break;case'2':value=2;//alertvalue;break;default:value=null;//alertvalue;break;}在getJSON success callback中使用$.root.empty。代码可以工作,基本上当用户选择三个选项时它可以工作,迷你图片出现在地图上,我的问题是当用户选择新图片时如何删除当前图片您尝试过我以前的评论吗?我得到了它来工作您的代码帮助,但我使用了$'.root'.sides.remove
$(".select_picture").change(function(){
 var value;
 x=document.getElementById("choice").value; // get the value of the select option stores it in x
switch(x)
{
        case '0':                        //assign a case and the value, for my statement
            value=0;
            // alert(value);
            break;
        case '1':
                value=1;
                // alert(value);
            break;
        case '2':
                value=2;
                // alert(value);
            break;
        default: 
                value=null;
                // alert(value);
            break;
}

if(value!=null)                        //if the value select is not null it would execute
{
    //alert(value)
    $.getJSON('data'+value+'.js',function(items){              //gets the json coordinates from the file, data is the name plus the value and the type of file
        $.each(items,function(i,val){                           
            root=$(".root")                                     //created a handler on the div where the map is in the html file
            image=$("<img id='img'>").attr('src',imgs[value]).css({left:val[0],top:val[1]})     //
            root.append(image);
        })
    })
}