0

How can I assign a jquery function in my css stylesheet? For eg. I have the following css

div{width: 300px; height: 200px; background-color: red;}

Is this the way?

div{width: $func_width; height: $func_height; background-color: $func_color;}
3
  • 2
    Short answer: you can't. Sorry. Commented Aug 2, 2013 at 12:26
  • use SASS [Sass is an extension of CSS that adds power and elegance to the basic language] Commented Aug 2, 2013 at 12:28
  • You need to do this in javascript, javascript is for javascript and css is for css only. Commented Aug 2, 2013 at 12:30

3 Answers 3

1

No, You can't. Better you try jquery css

$('div').css({'width':$func_width,'height': $func_height,'background-color': $func_color});
Sign up to request clarification or add additional context in comments.

Comments

0

You can't do that. But you can assign those function as a css property dynamically to HTML elements with jQuery.

Comments

0

Try this

$(document).ready(function(){
  $('div').css({'width':$func_width,'height': $func_height,'background-color': $func_color});


 // of you can use
 $('div').css('width' , $func_width);
 $('div').css('height' , $func_heigh);
});

Hope it will help

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.