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

时间:2015-10-06 17:35:42

标签: javascript html css

$(".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);
        })
    })
}

});

0 个答案:

没有答案