I have buttons with a class named nav, when a button is clicked the ID is read and the variable "pre" is set to the ID. Once the variable is set I'm removing part of the id, "-link". This part is working fine but could be where my problem is being created. Once "-link" has been removed I'm trying to use the remainder of pre to target the id of a div on the page and animate it. So I use another variable to hack together...
curr = '$("#'+pre+'")';
This "appears" to create what I need but when I target curr in my animation nothing happens. Probably b/c I have created a string and this is where my knowledge begins to fade.
Below is the complete function. I plan to use this with multiple buttons that have corresponding div's so it would be nice to use a single function for the whole class.
var pre = null;
var curr = null;
$('.nav').click(function(){
pre = $(this).attr("id");
pre = pre.substring(0, pre.indexOf("-link"));
curr = '$("#'+pre+'")';
alert(curr);
curr.animate({opacity:1}, {
duration:250,
queue:true,
complete:function(){
// alert("calling moveOld");
moveOld();
}
});
});