エリア タグの ID に対応するオブジェクト値をアラートすることができません。
私のコードは、
$(document).ready(function () {
$(".wholecirclewrapper area").click(function(){
if($(this).hasClass("active")) {
return false;
}
var choice = $(this).attr("id");
$.each(results.States, function(i, item) {
var st=results.States[i].Name;
if(choice==st)
{
alert(results.States[i].ISHI);
}
});
});
});
私のHtmlコードは
<div id="mapdiv">
<img src="india.gif" alt="India" usemap="#indiamap" />
<map name="indiamap" class="wholecirclewrapper">
<area class="specificshelfdiv1" id="AndraPradesh" shape="rect" coords="0,0,82,126" href="#" />
<area class="specificshelfdiv2" id="ArunachalPradesh" shape="circle" coords="90,58,3" href="#" />
<area class="specificshelfdiv3" id="Assam" shape="circle" coords="124,58,8" href="#" />
</map>
</div>
私の外部jsonは次のようになります
var results={"States":[
{ "Name" : "AndraPradesh" , "ISHI" : "19.5 (Serious)" ,"Literacy rate" : "67.7" ,"Population rate" : "84,665,533" ,"NFHS" : "29.8" ,"Tap water" : "69.9"},
{ "Name" : "ArunachalPradesh" , "ISHI" : "Not estimated" ,"Literacy rate" : "67" ,"Population rate" : "1,382,611" ,"NFHS" : "29.6" ,"Tap water" : "65.5"},
{ "Name" : "Assam" , "ISHI" : "19.8 (Serious)" ,"Literacy rate" : "73.2" ,"Population rate" : "31,169,272" ,"NFHS" : "35.8" ,"Tap water" : "10.5"}
]
};
私は経由でjsonを呼び出しています
<script src="json_states.json" type="text/javascript"> </script>
私は何を間違っていますか?