要素のStyleを変更する <移動>

Markをleft=155pxからLeft=35pxに移動する。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Map_Guide</title>
<script type="text/javascript">
<!--
function markMove() {
//  alert(document.posReq.number.value);
//  alert("onblur発生");
//  var posNumber = document.posReq.number.value;
    var posNumber = parseInt(document.posReq.number.value);
    alert(posNumber);
    document.getElementById("mark").style.left="35px";
}
-->
</script>
</head>
 
<body>
<div style="position:relative; margin: 10px auto; border: #333 solid thin; width:302px;">
<img src="Map.png" style="border: #333 dashed 1px;">
<div id="mark" style="border:#F00 solid 1px; width:50px; height:50px; position:absolute; left:155px; top:35px;"></div>
<form name="posReq" style="margin:0px 25%;">
位置番号は?<input type="text" name="number" onblur="markMove();" size="1">
</form>
</div>
</body>
</html>
カテゴリー: Javascript 関数 タグ: , パーマリンク