質問編集履歴
2
モーダルダイアログについて
test
CHANGED
File without changes
|
test
CHANGED
@@ -309,3 +309,283 @@
|
|
309
309
|
これを、ボタンを押すと手の画像が表示されて
|
310
310
|
|
311
311
|
アラートで結果が出る。という動作にしたいです
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
```javascript
|
316
|
+
|
317
|
+
//var value=prompt("呼ばれたい名前を入力するかしらっ、、、!");//
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
//まずは、じゃんけんの手を数値化させてあげる//
|
322
|
+
|
323
|
+
var images = new Array ("img/choki.png","img/guu.png","img/paa.png");
|
324
|
+
|
325
|
+
console.log(images[1]);
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
//数値化させた手をランダムで取るように&整数で表示//
|
330
|
+
|
331
|
+
//window.setInterval(getPC_hand,100);//
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
var random = 9;
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
function getPC_hand(){
|
342
|
+
|
343
|
+
var a = document.getElementById("td1");
|
344
|
+
|
345
|
+
random = Math.floor(Math.random() *3);
|
346
|
+
|
347
|
+
a.innerHTML= "<img src ='"+images[random]+"' id='PC' width='150px:'>";
|
348
|
+
|
349
|
+
window.setTimeout(getPC_hand,100);
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
getPC_hand();
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
var dialog = document.querySelector("dialog");
|
362
|
+
|
363
|
+
var btn_show = document.getElementById("myHand");
|
364
|
+
|
365
|
+
btn_show.addEventListener('click', function() {
|
366
|
+
|
367
|
+
dialog.show();
|
368
|
+
|
369
|
+
}, false);
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
function come_hand(myHand){
|
378
|
+
|
379
|
+
var b = document.getElementById("td2");
|
380
|
+
|
381
|
+
b.innerHTML= "<img src ='"+images[myHand]+"' id='PC' width='150px:'>";
|
382
|
+
|
383
|
+
};
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
function come_hand(myHand){
|
388
|
+
|
389
|
+
var b = document.getElementById("modal");
|
390
|
+
|
391
|
+
if (myHand === random){
|
392
|
+
|
393
|
+
window.alert("あいこ!!"+value+"もっかいやる?");
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
//勝ちの判定
|
398
|
+
|
399
|
+
if (myHand === 1 && random === 0){
|
400
|
+
|
401
|
+
window.alert ("勝ちい~~!"+value+"おめでとう~(*´ω`)");
|
402
|
+
|
403
|
+
}
|
404
|
+
|
405
|
+
if (myHand === 2 && random ===1){
|
406
|
+
|
407
|
+
window.alert ("勝ちい~~!"+value+"おめでとう~(*´ω`)");
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
if (myHand === 0 && random ===2){
|
412
|
+
|
413
|
+
window.alert ("勝ちい~~!"+value+"おめでとう~(*´ω`)");
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
//負け判定
|
418
|
+
|
419
|
+
if (myHand === 1 && random ===2){
|
420
|
+
|
421
|
+
window.alert (""+value+"の負けえ。。。残念(´;ω;`)");
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
if (myHand === 2 && random ===0){
|
426
|
+
|
427
|
+
window.alert (""+value+"の負けえ。。。残念(´;ω;`)");
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
if (myHand === 0 && random ===1){
|
432
|
+
|
433
|
+
window.alert (""+value+"の負けえ。。。残念(´;ω;`)");
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
/*①HTMLで動かしたい関数を書く
|
444
|
+
|
445
|
+
②渡したい値(引数)を書いててもいい~
|
446
|
+
|
447
|
+
③関数()←引数が入る箱
|
448
|
+
|
449
|
+
④渡された引数を使いたい場所に箱の名前をおいてあげる*/
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
```
|
454
|
+
|
455
|
+
```HTML
|
456
|
+
|
457
|
+
<html lang="ja">
|
458
|
+
|
459
|
+
<!--~の(要素)、~は(属性)、~です(属性値)-->
|
460
|
+
|
461
|
+
<head>
|
462
|
+
|
463
|
+
<meta charset="utf-8">
|
464
|
+
|
465
|
+
<title>じゃんけんげーむ</title>
|
466
|
+
|
467
|
+
<meta name="utf-8">
|
468
|
+
|
469
|
+
<link href="stylesheet.css" rel="stylesheet">
|
470
|
+
|
471
|
+
</head>
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
<body>
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
<!--うぇぶページぽくヘッダーを作るべし-->
|
480
|
+
|
481
|
+
<header class="header">
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
<div class="beako">
|
486
|
+
|
487
|
+
<img src="img/beako.png" class="img_beako">
|
488
|
+
|
489
|
+
<p>じゃんけんするのよ!</p>
|
490
|
+
|
491
|
+
<h3 style="text-align:right;">すばるの下にあるボタン推してみるのよ!</h3>
|
492
|
+
|
493
|
+
</div>
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
<nav class="nav">
|
498
|
+
|
499
|
+
<ul>
|
500
|
+
|
501
|
+
<li><a href="file:///C:/Users/81804/OneDrive/%E3%83%87%E3%82%B9%E3%82%AF%E3%83%88%E3%83%83%E3%83%97/%E7%B7%B4%E7%BF%92%E3%81%AA%E3%81%AE%EF%BD%9E%EF%BD%9E%EF%BD%9E/%E3%82%8B%E3%83%BC%E3%81%A1%E3%82%83%E3%82%93.html">るーちゃん</a></li>
|
502
|
+
|
503
|
+
<li><a href="file:///C:/Users/81804/OneDrive/%E3%83%87%E3%82%B9%E3%82%AF%E3%83%88%E3%83%83%E3%83%97/%E7%B7%B4%E7%BF%92%E3%81%AA%E3%81%AE%EF%BD%9E%EF%BD%9E%EF%BD%9E/%E3%81%8A%E3%81%97%E3%81%A6%E3%81%BF%EF%BC%9F.html">おしてみ?</a></li>
|
504
|
+
|
505
|
+
<li><a href="#">えへへ</a></li>
|
506
|
+
|
507
|
+
</ul>
|
508
|
+
|
509
|
+
</nav>
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
</header>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
<table class="table">
|
520
|
+
|
521
|
+
<tr>
|
522
|
+
|
523
|
+
<td id="td1"></td>
|
524
|
+
|
525
|
+
<td id="td2"></td>
|
526
|
+
|
527
|
+
</tr>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
<tr>
|
532
|
+
|
533
|
+
<td>
|
534
|
+
|
535
|
+
<img src="img/ekidona.png" class="ekidona" width="300px" height="270px">
|
536
|
+
|
537
|
+
</td>
|
538
|
+
|
539
|
+
<td id="subaru">
|
540
|
+
|
541
|
+
<img src="img/subaru.png" width="250px" height="270px">
|
542
|
+
|
543
|
+
</td>
|
544
|
+
|
545
|
+
</tr>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
<tr>
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
<!--モーダルダイアログ-->
|
554
|
+
|
555
|
+
<dialog>
|
556
|
+
|
557
|
+
<p id="modal"></p>
|
558
|
+
|
559
|
+
</dialog>
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
<td colspan="3" id="col">
|
564
|
+
|
565
|
+
<input type="button" value="ぐ~" id="myHand" onclick="come_hand(1)">
|
566
|
+
|
567
|
+
<input type="button" value="ちょき" id="myHand" onclick="come_hand(0)">
|
568
|
+
|
569
|
+
<input type="button" value="ぱー" id="myHand" onclick="come_hand(2)">
|
570
|
+
|
571
|
+
</td>
|
572
|
+
|
573
|
+
</tr>
|
574
|
+
|
575
|
+
</table>
|
576
|
+
|
577
|
+
</div>
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
</body>
|
582
|
+
|
583
|
+
<script src="javascript2.js"></script>
|
584
|
+
|
585
|
+
</html>
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
```
|
1
画像を付け加えました
test
CHANGED
File without changes
|
test
CHANGED
@@ -291,3 +291,21 @@
|
|
291
291
|
多分、同期比同期の話の問題だと思うのですが
|
292
292
|
|
293
293
|
助言いただけると嬉しいです。
|
294
|
+
|
295
|
+

|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
ボタンを押すと、先に結果が表示され
|
300
|
+
|
301
|
+
おkを押すと、手の表示がされます。
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+

|
308
|
+
|
309
|
+
これを、ボタンを押すと手の画像が表示されて
|
310
|
+
|
311
|
+
アラートで結果が出る。という動作にしたいです
|