Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery CSS Opacity

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';     } }); 
like image 826
Mike Avatar asked May 07 '13 13:05

Mike


People also ask

What is fadeTo in JQuery?

The fadeTo() method gradually changes the opacity, for selected elements, to a specified opacity (fading effect).

Can you fade an element to a desired value of opacity using JQuery?

fadeTo() method animates the opacity of the matched elements. It is similar to the . fadeIn() method but that method unhides the element and always fades to 100% opacity.

How do you change the opacity of an element?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).


1 Answers

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.

like image 83
rdp Avatar answered Oct 09 '22 04:10

rdp