I'm new to jQuery and I'm trying to set a variable when a link is clicked. Then when another link is clicked, it reads the variable and, using an if/else if statement, runs the appropriate code.
I'm not sure I have the correct syntax for some of these things. Any help would be awesome.
I'm not sure I have the correct syntax for some of these things. Any help would be awesome.
Code:
$(function() {
$('a.click_rotors').click(function() {
if ($current_link = "bases1") {
$('#bases1').fadeOut(function () {
$('#rotors1').fadeIn();
});
} else {
$('#onesies').fadeOut(function () {
$('#rotors1').fadeIn();
});
};
$current_link = "rotors1";
});<!--close click function-->
$('a.click_bases1').click(function() {
if ($current_link = "rotors1") {
$('#rotors1').fadeOut(function () {
$('#bases1').fadeIn();
});
} else {
$('#onesies').fadeOut(function () {
$('#bases1').fadeIn();
});
};
$current_link = "bases1";
});<!--close click function-->
$('a.click_onesies').click(function() {
if ($current_link = "rotors1") {
$('#rotors1').fadeOut(function () {
$('#onesies').fadeIn();
});
} else {
$('#bases1').fadeOut(function () {
$('#onesies').fadeIn();
});
};
$current_link = "onesies";
});<!--close click function-->
});

Comment