Ulises
Ulises

Reputation: 381

How to write a CSS shorthand Value in JQuery?

How can I get this CSS declaration:

 background: #232222 url("../img/big-team.jpg") no-repeat fixed;

In here:

$('.class ').css( 'background',  ' //code should be injected here ' );

Thank you in advance!

Upvotes: 0

Views: 63

Answers (3)

Head In Cloud
Head In Cloud

Reputation: 2051

You can also try by css Shorthand properties

   $(".class").css({
          "background-color":"#232222",
          "background-image": "url('../img/big-team.jpg')",
          "background-repeat":"no-repeat",
          "background-position":"fixed"
      });

Upvotes: 0

Alessio Cantarella
Alessio Cantarella

Reputation: 5201

Just copy and paste your CSS declaration:

$('.class').css('background', '#232222 url("../img/big-team.jpg") no-repeat fixed');

Upvotes: 1

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

Just you use in your css like this:

$('.class ').css( 'background',  '#232222 url("../img/big-team.jpg") no-repeat fixed' );

Upvotes: 0

Related Questions