Several people have an example of using setAttribute that I like. However, it is assumed that you do not have installed styles. I could do something like:
nFilter.setAttribute('style', nFilter.getAttribute('style') + ';width:330px;float:left;');
Or turn it into a helper function as follows:
function setStyle(el, css){ el.setAttribute('style', el.getAttribute('style') + ';' + css); } setStyle(nFilter, 'width:330px;float:left;');
This ensures that you can add styles to it continuously, and it will not remove the style currently set, always adding to the current styles. It also adds an extra half-point, so if there is a style ever missing, it will add another to make sure it is completely separate.
stuyam Aug 14 '17 at 15:47 2017-08-14 15:47
source share