I wrote a jquery code that is going to expand certain elements on hover. I want the code to only expand if not expanded. Here is my code. It doesn’t seem to be working correctly.
$(document).ready(function() {
var labelstatus = 0;
});
$(document).ready(function() {
$("a.rm").hover(function () {
if (labelstatus != 1){
$("#expensereduction,#envimpact,#mtextlft,#initaud,#energaud").fadeOut();
var currentFontSize = $('.initiate').css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10);
var newFontSize = currentFontSizeNum*3;
$('.initiate').delay(500).animate({
fontSize: newFontSize
});
return false;
var labelstatus = 1;
}
else {
}
});
});
You are declaring local variables inside the functions, so they are independent of each other. Also, you get a new variable each time, so the previous value doesn’t persist.
Also, you are calling
returnbefore assigning the variable, which will exit out of the function, so the assignment will never happen.You need to declare the variable in a scope outside the functions:
Also: the
parseFloatfunction doesn’t have a radix parameter.