On my website, I have div layers that if you hover, it changes the opacity from .3 to 1, and when you hover out, it goes to 1 back to .3.
The odd thing I'm noticing is that it changes to:
<div id="penta1" style="height: 945px; width: 380px; opacity: 0.30000000000000004;">
While some instances it reverts back to:
<div id="penta1" style="height: 945px; width: 380px; opacity: 0.3;">
My code is rather awkward, I was kind of dazed and frustrated while trying to get it to work, so don't yell at me in the comments that it is bad. I know it's bad. However, for those of you who are OCD about code optimization and neatness, feel free to organize, and condense to your hearts desire:
var contentWidth;
var allPenta = '#penta1,#penta2,#penta3,#penta4';
var allButton = '.button1,.button2,.button3,.button4';
var allFullPenta = '#pentafull1,#pentafull2,#pentafull3,#pentafull4'
function simplyWidth(wrapper, menu1, content, pentas){
var menu = $(menu1).width();
var wrapperwidth = $(wrapper).width();
var newWidth = wrapperwidth-menu;
var widgetWidth = newWidth/4;
contentWidth = newWidth;
$(content).css("width", newWidth);
$(pentas).css("width", widgetWidth);
};
var contentHeight
function simplyHeight(footer, bottom, wrapper, pentas){
var footheight = $(footer).height();
var bottomalign = $(bottom).height();
var wrapperheight = $(wrapper).height();
var newHeight = footheight + bottomalign;
var newnewHeight = wrapperheight - newHeight;
contentHeight = newnewHeight;
$(pentas).css("height", newnewHeight);
};
function simplyDimension(){
$(allFullPenta).css("width", contentWidth);
$(allFullPenta).css("height", contentHeight);
}
var stoppable = true;
function simplyHighlight(penta){
$(penta).fadeTo(0,.3)
$(penta).mouseenter(function(){
if (stoppable == true) {
$(penta).stop();
$(penta).fadeTo(200,1);
};
});
$(penta).mouseleave(function(){
if (stoppable == true) {
$(penta).stop();
$(penta).fadeTo(300,.3);
};
});
}
function simplySpan(button, fullpenta){
$(button).click(function(){
stoppable = false;
$(allPenta).hide(400);
$(allFullPenta).hide(400);
$(fullpenta).show(400);
});
};
function simplyMaster(){
simplyHeight('#contentfoot', '.bottomalign', '#wrapper', '#penta1,#penta2,#penta3,#penta4');
simplyWidth('#wrapper','#menu1','#content','#penta1,#penta2,#penta3,#penta4');
$(window).resize(function(){
simplyWidth('#wrapper','#menu1','#content','#penta1,#penta2,#penta3,#penta4');
simplyHeight('#contentfoot', '.bottomalign', '#wrapper', '#penta1,#penta2,#penta3,#penta4');
simplyDimension()
});
simplyHighlight('#penta1');
simplyHighlight('#penta2');
simplyHighlight('#penta3');
simplyHighlight('#penta4');
simplyDimension();
$(allFullPenta).hide();
simplySpan('.button1', '#pentafull1');
simplySpan('.button2', '#pentafull2');
simplySpan('.button3', '#pentafull3');
simplySpan('.button4', '#pentafull4');
};
You'll want to take your attention to the "simplyHighlight" function, as that is the primary source of what changes the div's opacity. The rest of the functions deal with transitions, and resizing.