Using a variable for .css position 'type'

Using Jquery, and I’m trying to make a element positioned either from the top or bottom based on where it is in a grid.

if ( > container_height) {
     var position_type = "bottom";
} else {
     var position_type = "top";

and then apply it like so


This isn’t working. Anyone know a reason why? Can’t seem to find anything on google, but maybe I’m not using the correct term.:confused:

Thanks for any kind of help/insight.

okay, came up with a solution, but it’s pretty ‘clunky’.

		$('<div class="term_definition"><p><b>' + title + '</b>' + term + '</p><img src="/images/close_button.png" class="definition_close" /></div>').hide().css({"width":width,"height":width}).appendTo($(benefit_grid_term).parent('dl'));

		var target_div = $('.term_definition');
		if ( > container_height) {
		} else {
		if (position.left+width > container_width) {
			var right = position.left+width;
		} else {

Seems like I should be able to place a variable in the css block for the name of the style i’m messing with instead of having to do new css methods for each one.