我映射了一个图像,我想把这些地图的id作为我的js变量的答案。
<img src="img/beyin3.png" alt="" usemap="#Map" />
<map name="Map" id="Map">
<area onclick="cevap = 'frontal'" id="frontal" alt="" title="" href="#" shape="poly" coords="228,485,282,375,323,305,353,269,400,166,402,120,412,84,341,114,265,142,198,187,130,243,90,331,94,406,107,461" />
<area alt="" title="" href="#" shape="poly" coords="388,572,464,533,522,509,615,477,670,452,701,409,736,372,736,348,625,332,555,333,498,351,444,374,385,402,337,451,301,489,312,528" />
<area alt="" title="" href="#" shape="poly" coords="456,274,562,273,656,283,741,286,804,249,790,210,728,174,695,145,655,118,579,104,547,99" />
<area alt="" title="" href="#" shape="poly" coords="757,460,837,456,876,443,894,411,904,380,904,347,889,330,871,303,855,280,846,278,830,278,799,309" />
</map>
<p style="text-align:bottom; margin-top:30%;">
<h1><p id="soru"></p></h1></center>
Javascript代码
function myFunction() {
var ran = Math.floor((Math.random() * soruCevap.length));
document.getElementById("soru").innerHTML = soruCevap[ran][0];
var cevap;
if(cevap.equals("frontal")){
document.getElementById("soru").innerHTML = cevap;
} else if(cevap.equals("temporal")){
} else if(cevap.equals("paryetal")){
} else if(cevap.equals("oksipital")){
}
}
答案 0 :(得分:0)
JavaScript没有equals
方法,除非您对某些数据类型进行了monkeypatched。可能你混淆了java和javascript。
你应该做的是,改变
if(cevap.equals("frontal"))
to,
if(cevap === "frontal")