Guest lewapryb Posted January 29, 2007 Share Posted January 29, 2007 Hi everybody!I have a question... I learn DOM from Java part and I would like to know can I create a node with a name that is chosen dynamically , I mean I want to have a function like that... public AddElement(to_which_node, "name of Element", type_of_element){ to_which_node.appendChild("name of Element");}is it possible????? - the dynamic names of Elements??? Link to comment Share on other sites More sharing options...
jesh Posted January 29, 2007 Share Posted January 29, 2007 I'm not sure with what language you are trying to accomplish this, but in javascript, it'd look something like this: function addElement(parent, element_id, element_type){ var element = document.createElement(element_type); element.id = element_id; parent.appendChild(element);} And you could use it like this: var div = document.getElementById("mydiv");addElement(div, "test", "p"); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now