Val
Val

Reputation: 17522

jquery opacity cross browser?

Is the the jQuery('#selector').css({'opacity':50}); cross browser?

The only reason i ask is because the line below that we'd normally use on css

-moz-opacity:.50; filter:alpha(opacity=50); opacity:.50;

Upvotes: 13

Views: 17357

Answers (3)

Andy
Andy

Reputation: 30135

Yes, it sets the css opacity or IE's opacity filter.

Upvotes: 4

davin
davin

Reputation: 45525

this is probably better:

$(element).fadeTo(0, 0.5);

Upvotes: 26

JasCav
JasCav

Reputation: 34632

Because jQuery is designed with cross-browser compatibility in mind, as long as the CSS opacity tag is supported in a browser, then, yes, your jQuery code is cross-browser. (Have you tried it out yet? You can head to jsfiddle.net to see if it is.)

For more information, here is the W3Schools page on opacity. Head there with various browsers and see if it works. (It looks like it works for me in all three major browsers.)

Upvotes: 0

Related Questions