function dungeonGen() {
mapMenuDiv.innerHTML = ""
for (var i = 1; i < 6; i++) {
for (var y = 1; y < 6; y++) {
genRoll = Math.floor(Math.random() * 10 + 1);
if (genRoll > 2) {
mapMenuDiv.innerHTML += '<div id="s'
+ i + 'b' + y + '" style="width: 50px; height: 50px; left: '
+ 50 * (y - 1) + 'px; top: ' + 50 * (i - 1) + 'px; position: absolute;"><img src=' + mapBL1Img + ' onclick=roomNormal></img></div>'
}
if (genRoll === 1) {
mapMenuDiv.innerHTML += '<div id="s' + i + 'b' + y
+ '" style="width: 50px; height: 50px; left: ' + 50 * (y - 1)
+ 'px; top: ' + 50 * (i - 1) + 'px; position: absolute;"><img src=' + mapBL2Img + ' onclick=roomNormal></img></div>'
}
if (genRoll === 2) {
mapMenuDiv.innerHTML += '<div id="s' + i + 'b' + y
+ '" style="width: 50px; height: 50px; left: ' + 50 * (y - 1) + 'px; top: ' + 50 * (i - 1) + 'px; position: absolute;"><img src=' + mapBL3Img + ' onclick=roomNoGem></img></div>'
}
}
}
}
尝试使用onClick,onclick和onclick javascript:roomNormal。但是,图像点击没有任何反应。
答案 0 :(得分:0)
你可能正在寻找
<img src="' + mapBL2Img + '" onclick="roomNormal()" />
调用名为roomNormal
的javascript 函数