Need to know how I can use a Jquery var in a CSS property, I’ve searched around the net but haven’t found any answers that refer to what I want, and also I’m not the greatest coder to figure this out. Have not used Jquery alot!
Code JQUERY:
<script>
//find window height
var winHeight = $(window).height();
alert(winHeight);//=692
$('menuHolder').css(height(), winHeight);
</script>
There are many issues with your code:
menuHolderis not a valid html tag.height()is a function call which I cannot imagine should ever return the string"height".Suppose your html looks like this:
Note that the tag in question must have id attribute set to “menuHolder”. If you have more than one menuHolder, then you should use the
classattribute instead.Then your js should be:
http://jsfiddle.net/93hFW/
or
http://jsfiddle.net/93hFW/1/
If you have are using the
classattribute instead as suggested above, then you should use a.(dot) instead of the#to prefix the jQuery selector.