How can i create html elements dynamically?

First of all i'm still in the learning process and slowly trying to push myself to the next level in web development so please help me
I'm making a small word document maker, it can make text dynamically and insert images dynamically too. but i cannot use a simple text area because i want to make it dynamically. i cannot insert images with a textbox. So i decided to make an iframe and made another html tag inside of it for the work area and i was planning to make the text and the inserting of images dynamically inside the iframe>html. But I don't have a clue and an idea how to do this. i know its possible creating the text and inserting images there but I don't know how to build them dynamically. I was thinking while typing its inserting html elements like paragraph tags and such.. can anyone help or give me an idea?


  • You can create dynamic elements using something like below; you may also want to experiment with the various properites, function, etc to get an idea of what can be done.



    function addEle(eleType, eleID, bindTo, eWidth, eHeight) {

    try {

    if(document.getElementById("some id") == null ||
    document.getElementById("some id") == undefined) {

    var elem = document.createElement(eleType);
    var htag = document.getElementById(bindTo); = eleID; = "#ffff00"; = "arial, verdana, sans-serif"; = "22px"; = eWidth + "px"; = eHeight + "px";
    elem.value = "inside of the text area";
    elem.readOnly = 1;

    } catch(e) { alert("could not create " + eleType); }

    click me
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion