I want to be able to dynamically change width and height in a div that gets created by a function. The code below works but the style rules gets added directly in the HTML document, which is something I want to avoid. Instead I want the properties to be added directly to the CSS file. Is there a way to achive that?
...function(width, height) {
var div = $('<div/>', {
class': 'window',
width': width,
height': height
}).appendTo('#content');
}
why do you need to add a class in CSS file with jquery? You can’t do this directly. You can add a
<style>....</style>tag in your HTML page’s<head>tag with jQuery which is support you much. You can use the following methods to solve this:OR
OR
But remember you need to use plugin for use
$.rule.