Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tic-tac-toe-game #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">

<!-- set viewport to device width to make site responsive -->
Expand All @@ -9,6 +10,7 @@
<!-- bootstrap css -->

<!-- custom styles -->
<link rel="stylesheet" type="text/css" href="main.css" media="screen" />

<title>Tic Tac Toe</title>
</head>
Expand All @@ -28,30 +30,33 @@ <h1>Tic Tac Toe</h1>

<!-- you can nest rows inside of columns! -->
<!-- our board has 3 rows, each with 3 columns inside -->
<div class="row">
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
</div>

<div class="row">
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
<table>
<tr id="row1">
<td id= "1" class="square"></td>
<td id= "2" class="square a"></td>
<td id= "3" class="square"></td>
</tr>
<tr id="row2">
<td id="4" class="square b"></td>
<td id="5" class="square a b"></td>
<td id="6" class="square b"></td>
</tr>
<tr id="row3">
<td id="7" class="square"></td>
<td id="8" class="square a"></td>
<td id="9" class="square"></td>
</tr>
</table>
</div>

<div class="row">
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
<div class="col-xs-4 box"></div>
</div>
</div>
</div>
</div>

<!-- jquery -->
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>

<!-- custom script -->
<div style="text-align:center;"><button class="invisible" id="newGame">New game!</button></div>

</body>
</html>
39 changes: 34 additions & 5 deletions main.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
.square{
width:100px;
height:100px;
}

.a{
border-left:1px solid #000;
border-right:1px solid #000;
}

.b{
border-top:1px solid #000;
border-bottom:1px solid #000;
}

#container{
text-align:center;
}

#board {
margin-top: 10px;
display: inline-block;
margin-top:2%;

}
.invisible {
visibility:hidden;
}
.visible {
visibility:visible;
}


.box {
border: 1px solid black;
height: 150px;
}
table {
background-color: #FAFAAF;
text-align:center;
font: 400 30px/1.5 'Pacifico', Helvetica, sans-serif;
}
14 changes: 10 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// wait for DOM to load before running JS
$(function() {

// your code here

$(function)() {
var count = 0;
$(".box").click(function() {
if (count % 2 === 0) {
$(this).text("X");
} else if (count % 2 !== 0){
$(this).text("O");
}
count++;
});
});