Last active
September 17, 2016 20:01
-
-
Save Pan-Maciek/40e6fc189d2893b0035ef612916850b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>kółko i krzyżyk</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | |
| <script> | |
| var rozmiar = 3 | |
| var ruch = "x" | |
| var kolor = "black" | |
| $(document).ready(function () { | |
| $("#but1").on("click", function(){ | |
| $("#div1").html("") | |
| for (var j = 0; j < rozmiar; j++) { | |
| for (var i = 0; i < rozmiar; i++) { | |
| var a=$("<div>") | |
| .width(100) | |
| .height(100) | |
| .css("background", kolor) | |
| .css("margin-left", "5px") | |
| .css("display", "inline-block") | |
| .on("click", function(){ | |
| if (ruch == "x"){ | |
| ruch = "o" | |
| $(this).off("click").append($("<img>").attr("src", "x.png")) | |
| } else { | |
| $(this).off("click").append($("<img>").attr("src", "o.png")) | |
| ruch = "x" | |
| } | |
| }) | |
| $("#div1").append(a) | |
| }$("#div1").append("<br>") | |
| } | |
| }) | |
| $("#rozmiary").on("click", function(){ | |
| rozmiar = parseInt($(this).val()) | |
| }) | |
| $("#kolory").on("click", function(){ | |
| kolor = $(this).val() | |
| $("#div1 div").css("background", $(this).val()) | |
| }) | |
| }) | |
| </script> | |
| <style> | |
| #but1{ | |
| width: 100%; | |
| text-align: center; | |
| } | |
| div{ | |
| position: relative | |
| } | |
| div>img{ | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| height:100%; | |
| width:100%; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>T: for i tablice</h1> | |
| <select id="rozmiary"> | |
| <option value="3">3x3</option> | |
| <option value="4">4x4</option> | |
| <option value="5">5x5</option> | |
| <option value="6">6x6</option> | |
| </select> | |
| <select id="kolory"> | |
| <option value="black">czarny</option> | |
| <option value="blue">niebieski</option> | |
| <option value="green">zielony</option> | |
| <option value="gray">szary</option> | |
| </select> | |
| <button id="but1">generuj</button> | |
| <div id="div1"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment