Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

I am attempting to add this code to a dynamically created div element

style = "width:330px;float:left;"

This code creates the dynamic div

var nFilter = document.createElement('div');

nFilter.className = 'well';

nFilter.innerHTML = '<label>' + sSearchStr + '</label>';

I want to add the style after <div class=”well” but I do not know how to do it. Can someone help me with this?

1 Answer

0 votes
by (13.1k points)

You can use:
 

nFilter.style.width = '330px';

nFilter.style.float = 'left';

This would add an inline style to the element.

Want to learn Full Stack Development? Check out the Full Stack Developer course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Apr 10, 2021 in Web Technology by Jake (7k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...