The HTML code is like this
<div> <p> Owen Perry's works always have a nostalgic cinematic feel. The web designer has been involved in photography for three years. On circa 1983, Owen shows the photos he has taken from his travels in Canada and abroad since the beginning of 2011. His work is like a retro postcard, like a painting painted on kraft paper a long time ago. </p> <textarea class= "text" ></textarea> <button id= "sub" class= "but" ; reply </button> </div>
Originally feel that click the Reply button get <p></p> inside innerHTML use
function Onclickbut () {var = document.getelementsbyclassname ("but"), for (var i = 0;l=but.length,i<l;i++) {But[i]. onclick = function () {var node = this.parentnode.previoussbiling.previoussbiling.innerhtml;//Gets the contents of the P node}}}
But I don't know what's wrong.
Later felt that the use of
function Onclickbut () {var = document.getelementsbyclassname ("but"), for (var i = 0;l=but.length,i<l;i++) {But[i]. onclick = function () {var node = this.parentnode.childnodes.firstchild.innerhtml;//Gets the contents of the P node}}}
But they can't get it.
Then simply directly
function Onclickbut () {var = document.getelementsbyclassname ("but"), for (var i = 0;l=but.length,i<l;i++) {But[i]. onclick = function () {var node = this.parentNode.getElementsByTagName ("P") [0].innerhtml;//gets the contents of the P node}}}
Ask Daniel for a more convenient way!!
Using JS to get the node