I'm attempting to add this code to a dynamically created div element
style = "width:330px;float:left;"
The code in which creates the dynamic div
is
var nFilter = document.createElement('div'); nFilter.className = 'well'; nFilter.innerHTML = '<label>' + sSearchStr + '</label>';
My idea is to add the style after < div class="well"
but i don't know how i'd do it.
Inline styles are applied directly to the specific HTML element using the style attribute. In JavaScript the style property is used to get or set the inline style of an element. The following example will set the color and font properties of an element with id="intro" .
Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.
If you want all of the inline-styles as text, either get the style attribute (as you're doing) or use this. style. cssText .
nFilter.style.width = '330px'; nFilter.style.float = 'left';
This should add an inline style to the element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With