I’m using JQuery and bootstrap, and when I try to click the button that should invoke the function, it doesn’t work. I’ve looked in the developer console and there is nothing there, anyone know?
JavaScript
x
32
32
1
<html>
2
<head>
3
<title>Bill</title>
4
5
<link rel="stylesheet" href="css/bootstrap.min.css"/>
6
<link rel="stylesheet" href="css/jumbotron-narrow-me.css"/>
7
<script src="js/jquery-2.1.3.min.js"/>
8
<script src="js/bootstrap.min.js"/>
9
10
<script type="text/javascript">
11
var count=0;
12
13
$('#ocs').click(function(){
14
count++;
15
$('#cookies').html('0Cs : ' + count);
16
});
17
</script>
18
</head>
19
20
<body>
21
<div class="jumbotron">
22
<p class="lead">
23
welcome to opposition clicker, its amazing. it has one upgrade.
24
"opposition" when you get this, you will get +100 0Cs' every second.
25
</p>
26
<br><br/>
27
</div>
28
<div class="container" id="cookies">aasasa</div>
29
<button id="ocs" type="button" class="btn btn-lg btn-success">0Cs'</button>
30
</body>
31
</html>
32
Advertisement
Answer
You just need to close some script tags properly and place your script in the bottom:-)
JavaScript
1
32
32
1
<html>
2
3
<head>
4
<title>Bill</title>
5
<script data-require="jquery@*" data-semver="2.1.3" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
6
<link data-require="bootstrap@*" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
7
<script data-require="bootstrap@*" data-semver="3.3.1" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
8
</head>
9
10
<body>
11
<div class="jumbotron">
12
<p class="lead">
13
welcome to opposition clicker, its amazing. it has one upgrade.
14
"opposition" when you get this, you will get +100 0Cs' every second.
15
</p>
16
<br />
17
<br />
18
</div>
19
<div class="container" id="cookies">aasasa</div>
20
<button id="ocs" type="button" class="btn btn-lg btn-success">0Cs'</button>
21
<script type="text/javascript">
22
var count=0;
23
24
$('#ocs').click(function(){
25
count++;
26
$('#cookies').html('0Cs : ' + count);
27
});
28
</script>
29
</body>
30
31
</html>
32
PS:- I didn’t added the jumbotron-narrow-me.css in example because it is not available on plunker but hope it helps 🙂