pstein Posted February 13, 2016 Share Posted February 13, 2016 Assume I want to get the content/Value of the following (inner) element (and move it later into another element):< aside id="parent">< p class=" aaa bbb ccc"> ...... </p>< /aside>then the following code does not work:var pane = document.getElementsByClass("aaa bbb ccc")[0];var target = document.getElementsByClass("foobar")[0];target = pane.innerHTML;The following does not work as well:var pane = document.getElementsByClass("aaa.bbb.ccc")[0];var target = document.getElementsByClass("foobar")[0];target = pane.innerHTML;So how else should I code this?Peter Link to comment Share on other sites More sharing options...
dsonesuk Posted February 13, 2016 Share Posted February 13, 2016 (edited) 1) There is no function of getElementsByClass() it should be getElementsByClassName(); 2) You are asking it to assign innerHTML content of pane to target variable? not its innerHTML, so it will just overwrite var target = document.getElementsByClass("foobar")[0]; http://www.w3schools.com/jsref/met_document_getelementsbyclassname.asp Edited February 13, 2016 by dsonesuk 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