Witam mam taki problem że chciałbym w javascript bądź w jquery zrobić funkcje onclik i robię wg poradników na internecie na 3 sposoby (2 w javascript i 1 w jquery) i żadna nie działa.
tu kod z próbą na jquery bo na tej mi najbardziej zależy
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<script src="js/jquery-3.3.1.min.js"></script>
<title>Memory Game</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
<link href="https://fonts.googleapis.com/css?family=Spicy+Rice" rel="stylesheet">
<script type="text/javascript" src="js/memorygame.js"></script>
</head>
<body>
<div id="header">
<h1>Memory Game</h1><br><p> Inspired by Heroes game</p>
</div>
<div id="table">
<div class="card" id="" ></div>
<div class="card" id="c1"></div>
<div class="card" id="c2"></div>
<div class="card" id="c3"></div>
<div class="card" id="c4"></div>
<div class="card" id="c5"></div>
<div class="card" id="c6"></div>
<div class="card" id="c7"></div>
<div class="card" id="c8"></div>
<div class="card" id="c9"></div>
<div class="card" id="c10"></div>
<div class="card" id="c11"></div>
<div class="card" id="c12"></div>
<div class="card" id="c13"></div>
<div class="card" id="c14"></div>
<div class="card" id="c15"></div>
</div>
<div id="footer">
</div>
</body>
</html>
let cards = new Array(8);
const cards2 = ["1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png"];
let rand;
for (let i=0; i<16; i++){
rand = Math.floor(Math.random()*8);
cards[i] = cards2[rand]
$("#c"+i).click(function () {obracanie(i);})
}
function obracanie(nr){
alert(nr);
}