I am trying to access an element id of an HTML page from another page. I have seen other solutions but none have worked so far.
For example, if this is One.html
<input id="a" type="text"></input>
<p id="demo"></p>
I am trying to access the element id 'a' from Two.html to get the value that has been inputted using `
var thing = document.getElementById('a').value;
document.getElementById('demo').innerHTML = "the value is" + " " + thing;
you can use localStorage
for example in firstpage.html you save data with
var thing = document.getElementById('a').value;
localStorage.something = thing ;
then in your seconpage.html you can use it by
document.getElementById("demo").innerHTML=localStorage.something;
sorry I don't have enough reputation to leave this as a comment but just a heads up, input tags are standalone tags.
Example:
<body>
<input type="text" id="a" />
</body>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.