I have a bunch of divs that i'm using to dynamically change style with jquery.css(). The way I'm pulling the property is to return the div id of the container.
In this case, stylechange = "fontFamily" because that's the ID of the main container.
str = the value of the checked option.
I've console.log() and alert() to debug this, and i'm getting strings returned, and when i manually set the properties and values it works.
However, using variables as either the property or the value does not work, and I'm stumped.
Javascript:
var stylechange = "";
var str = "";
$("select").change(function(){
stylechange = $("select option:selected").parents(".styleoptions").attr('id');
str = $("select option:selected").text();
$(".elementselected textarea").css({stylechange: str});
})
HTML: This is the div
<div class="ui-draggable ui-resizable addeddiv elementselected absolute move" style="position: relative; display: block;">
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 90; display: block;"></div>
<div class="ui-resizable-handle ui-resizable-s" style="z-index: 90; display: block;"></div>
<div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;"></div>
<div class="removethis ui-resizable-handle absolute">X</div>
<textarea type="textbox" class="addedtext"></textarea>
</div>
This is the HTML that the css gets the ID from
<div id="fontFamily" class="styleoptions" style="display: block; text-transform: capitalize;">
<div class="optiontitle" style="text-transform: capitalize;">family</div>
<div class="options" style="text-transform: capitalize;">
<select style="text-transform: capitalize;">
<option style="text-transform: capitalize;">palatino</option>
<option style="text-transform: capitalize;">arial</option>
<option style="text-transform: capitalize;">verdana</option>
<option style="text-transform: capitalize;">times new roman</option>
</select>
</div>
</div>
varin front ofstylechangeto actually declare it as a variable. AndfontFamilyisn't a CSS property, butfont-familyis