Issue
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.
Solution
nFilter.style.width = '330px';
nFilter.style.float = 'left';
This should add an inline style to the element.
Most CSS names are mapped 1:1 to the JavaScript property. CSS properties with dashes in their names are converted to camel case. For more information see the blue information box at https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
Answered By - Dharman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.