manojnaanak Posted May 9, 2013 Share Posted May 9, 2013 (edited) Hello Everyone, i want such a parent link on which i click it add another child link under itself if there is any script plz provide me. image link for better understand: http://datanova.co.in/dnitest/test/edit.gif thanking you very much Edited May 9, 2013 by manojnaanak Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2013 Share Posted May 9, 2013 Your image link doesn't work. How much Javascript do you know? Link to comment Share on other sites More sharing options...
manojnaanak Posted May 10, 2013 Author Share Posted May 10, 2013 (edited) Your image link doesn't work. How much Javascript do you know? I can implement and customize little bit , i don't know more about js. Edited May 10, 2013 by manojnaanak Link to comment Share on other sites More sharing options...
justsomeguy Posted May 10, 2013 Share Posted May 10, 2013 You can set up a link like this: <a onclick="add_child(this);"> The add_child function will take a parameter, which will be the element that you clicked on. You can use the DOM methods and properties to insert the new node after the one you clicked on. Javascript doesn't have an insertAfter method, but it has insertBefore and a nextSibling property. So your link will need to have at least one element after it (even if it's hidden and doesn't show anything), but you can do something like this: function add_child(link){ var new_link = document.createElement('a'); new_link.innerHTML = 'new child'; link.parentNode.insertBefore(new_link, link.nextSibling);} 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