update element , with selection choices
I am creating a form, with colorwheel, and text colour selection.
Essentially, we have a logo that will load dynamically in the element ( div ) container.
The colorwheel, will create the bg colour The radio buttons allow to select text colour.
Any js gurus, know how to create the js to crea开发者_开发百科te the div, that changes bg colour and text colour of the preview div as per the image.
Very basic example ( image paths changed ) but works. http://www.jsfiddle.net/QZuA5/ Essentially its the preview div, I want to create. We can place logo dynamically using absolute positioning.
So essentially its the js to create the div placeholder bg colour and font text colour, that will parse valuse when we submit the form.
Cheers
Regarding the line: *create the div, that changes bg colour and text colour of the preview div as per the image. *
In raw Javascript, you can dynamically create a div like this:
var div = document.createElement("DIV");
You can access the styles of div
with its .style
property to change everything else you need, whenever you want:
div.backgroundColor = "#123456";
div.style.color = "green";
div.style.height = "100px";
Then you can append div
anywhere you want with the .appendChild
method:
document.appendChild(div);
or
document.getElementById('anotherElement').appendChild(div);
精彩评论