I am having an issue with an ‘if else if’ function in jQuery. The last two statements of my code are not detected at all, so nothing happens when i expect a page to load. Does anybody know what is wrong with this?
function pageloader() {
var position = $('#slideInner').css('marginLeft');
if (position >= '-936px') {
// load the page contents
$('#blogs').load('pagetwo.html #blog');
// hide the loading box
loadoff();
$('#portfolio').empty();
}
else if (position = '-1872px') {
$('#portfolio').load('pagethree.html #homepage');
loadoff();
$('#blogs').empty();
}
else if (position = '-2808px') {
$('#contact').load('pagefour.html #homepage');
// hide the loading box
loadoff();
}
else {
alert('all posibilities exausted');
}
}
The
ifconditions are wrong.Replace
=by==in both these linesIf it was a typo fine, otherwise FYI