I have some HTML data stored on JavaScript variable and I want to fetch the data from that variable
I'm trying to get it by getElementById() method. Please also keep it in mind that I have used same id in every div. I know it's not good way but there is some restriction. So I need the data from 2nd Div.
var complexArray = "<div id="
post ">First content<\/div><div id="
post ">Second Content<\/div><div id="
post ">Third Content<\/div>";
var data = document.getElementById('post').innerHTML;
alert(data);
document.getElementById, unsurprisingly, searches the document, not some random string of HTML.