0

Why won't this set the css for the .btn-post element. I've tried putting it in a function as well.

var variable = "hsla(359, 61%, 30%, 1);"

$('.btn-post').css('background', variable );
6
  • you could use a semicolon after your first line Commented Apr 5, 2013 at 18:26
  • I've tried it. Still no luck. Commented Apr 5, 2013 at 18:27
  • take the ; outside of quotes Commented Apr 5, 2013 at 18:28
  • 2
    It does work: jsfiddle.net/32bfW Commented Apr 5, 2013 at 18:28
  • And which browser are you using to test? IE8 won't support HSLa colors. Commented Apr 5, 2013 at 18:34

2 Answers 2

1

May be you need a doc ready handler for it:

$(function(){
   var variable = "hsla(359, 61%, 30%, 1)";
   $('.btn-post').css('background', variable );
});
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, this was the problem. Loading issue. You're right. Tahnks Jai
0

Try this:

   var variable = "hsla(359, 61%, 30%, 1)";
   $('.btn-post').css('background-color', variable );

DEMO HERE

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.