I can't seem to push new data in the array, and then update the output field with the new data. Probably an obvious problem, but not for my newbie skills.
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="jquery-2.1.1.min.js"></script>
<title>VB</title>
</head>
<body>
<output id="crumMenuOutput"></output>
<br /><br />
<button type="button" id="test">Ny takst</button>
<script>
$(document).ready(function(){
var menuArray = new Array;
menuArray.push("test1"); // add test data to array
$("button").click(function() {
menuArray.push("test2"); // fail to add data on button click
alert($(this).attr('id')); // just at test to see function working
});
This should update OUTPUT field with more entries
if(menuArray.lenght !== 0){
$.each(menuArray, function(i, val) {
if(i == menuArray.length - 1) var spacer = ""; else var spacer = " > ";
$('#crumMenuOutput').append(val + spacer);
});
}
});
</script>
</body>
</html>