I am pretty new to Javascript and JQuery.
Currently right now I'm trying to use .push
inside my function.
This should be triggered when a person clicks on a link, and add 1 to my array. After clicking on the click on the link I take a look at the variable pointTotal
, and find that there is nothing in the array.
If anyone can I would like to know what I'm doing wrong.
Javascript
var pointTotal = [];
$("#pointOne").click(function() {
pointTotal.push(1);
});
HTML
<div class ="quizSectionStress container-fluid">
<div class="rowOne rowStyle">
<div class = "answers col-xs-1 col-md-1">
<div class="btn-group questionGroups">
<button type="button" class="btn btn-default btn-md dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Answer <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#" id="questionOneOne pointOne" name="questionOneOne" value="1"><label>1</label></a></li>
<li><a href="#" id="questionOneTwo pointTwo" name="questionOneTwo" value="2"><label>2</label></a></li>
<li><a href="#" id="questionOneThree pointThree" name="questionOneThree" value="3"><label>3</label></a></li>
<li><a href="#" id="questionOneFour pointFour" name="questionOneFour" value="4"><label>4</label></a></li>
<li><a href="#" id="questionOneFive pointFive" name="questionOneFive" value="5"><label>5</label></a></li>
<li><a href="#" id="questionOneSix pointSix" name="questionOneSix" value="6"><label>6</label></a></li>
</ul>
</div>
</div>