Why is it not using the Math.Random I put in there. Thanks in advance.
$(function () {
$.ajax({
type: "GET",
url: "myFakeChannelData.xml",
dataType: "xml",
success: changeChannel
});
});
function changeChannel(xml) {
$('#layer').fadeOut(1000);
var $limit = 4;
$(xml).find("Channel").each(function($limit) {
var $channel = $(this);
var image = $channel.attr('image');
$("#click").click(function () {
$(".layer-container").empty();
$(".layer-container").append('<div class="layer1">' +
'<img class="" alt="" src="' + image + '" />' + '</div></div>');
$(".layer-container").append('<div class="layer2">' + '<img class="" alt="" src="' + image + '" />' + '</div></div>');
$(".layer-container").append('<div class="layer3">' + '<img class="" alt="" src="' + image + '" />' + '</div></div>');
$(".Channel").fadeIn(1000);
var random = Math.floor(limit * Math.random());
var myNewChannel = remix(random);
myNewChannel(random);
});
});
}
You’re referring to “limit” in that expression, but it should be “$limit”.
It was probably always coming out zero, since the undefined “limit” would be cast to zero for the multiplication.