jQuery CSS Opacity

JqueryCssBlockOpacity

Jquery Problem Overview


What's wrong? I want to change the opacity if #nav .drop is display:block;

jQuery(document).ready(function(){
    if (jQuery('#nav .drop').css('display') === 'block') {
        jQuery('#main').css('opacity') = '0.6';
    }
});

Jquery Solutions


Solution 1 - Jquery

jQuery('#main').css('opacity') = '0.6';

should be

jQuery('#main').css('opacity', '0.6');

Update:

http://jsfiddle.net/GegMk/ if you type in the text box. Click away, the opacity changes.

Solution 2 - Jquery

Try with this :

jQuery('#main').css({ opacity: 0.6 });

Solution 3 - Jquery

Try this:

jQuery('#main').css('opacity', '0.6');

or

jQuery('#main').css({'filter':'alpha(opacity=60)', 'zoom':'1', 'opacity':'0.6'});

if you want to support IE7, IE8 and so on.

Solution 4 - Jquery

try using .animate instead of .css or even just on the opacity one and leave .css on the display?? may b

jQuery(document).ready(function(){
if (jQuery('#nav .drop').animate('display') === 'block') {
    jQuery('#main').animate('opacity') = '0.6';

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMikeView Question on Stackoverflow
Solution 1 - JqueryrdpView Answer on Stackoverflow
Solution 2 - JqueryAlaridView Answer on Stackoverflow
Solution 3 - Jqueryed1nh0View Answer on Stackoverflow
Solution 4 - JqueryhoppieView Answer on Stackoverflow