I successfully created a div dynamically. But i was wondering is there a way to apply CSS style directly instead of applying style one by one using Javascript.
DEMO FIDDLE
You should use the className property:
className
divTag.className = "divdrag";
The div now has the appropriate class name and you just need to add all of your styling to that CSS class.
div
More info here
1.4m articles
1.4m replys
5 comments
57.0k users