Jump to content

getElementByElementName() similar to getElementByClassName() ?


Recommended Posts

Whenever I want to add something at the end inside an (the first) element which is identifiable by class name I can write:

var div = document.getElementsByClassName("myclassname")[0];
div.innerHTML = div.innerHTML + "foobar";

This works fine.

But what if there is no class name but only the element tag like in


How can I add "foobar" text at the end (after last span) but inside (!) the <cite> element?

Is there a function similar to getElementByElementName(...) which means I could write:

var div = document.getElementsByElementName("cite")[0];
div.innerHTML = div.innerHTML + "foobar";


Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...