I want to dynamically set the height of an element .selected
based on the screen height. $('.selected').css('height', height);
and $('.selected').height(height);
work but when another element becomes .selected
it doesn't get affected by this rule.
What I really want to do is something like this:
var s = $('<style>.selected{height:'+height+'px}</style>').appendTo(document.head);
...
// change the height later
s.remove();
s = $('<style>.selected{height:'+new_height+'px}</style>').appendTo(document.head);
Is there a better way to do this?
style
tag rather than to add a new one to override an existing rule, if possible.s.text('.selected{height:'+new_height+'px}');
?