OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get element by id from another page by JavaScript

  • Thread starter Thread starter stroibot
  • Start date Start date
S

stroibot

Guest
I have 2 pages index.html and about.html. In about.html there's a table aI need to get value from TD with id = 'id1' and assign it to some variable X to be used later at page index.html.

This would perfectly worked if I had it in one page.


Code:
var X = document.getElementById('id1').innerHTML;
alert(X); // 123

Code:
...
<td id='id1'>123</td>
...
But how to get value from id1 from about.html? I'd prefer JavaScript because I'm not so good with jQuery at the moment, but if it's not possible jQuery would be nice too.

<p>I have 2 pages <code>index.html</code> and <code>about.html</code>. In <code>about.html</code> there's a table aI need to get value from TD with <code>id = 'id1'</code> and assign it to some variable <code>X</code> to be used later at page <code>index.html</code>.</p>

<p>This would perfectly worked if I had it in one page.</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var X = document.getElementById('id1').innerHTML;
alert(X); // 123</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>...
<td id='id1'>123</td>
...</code></pre>
</div>
</div>

But how to get value from <code>id1</code> from <code>about.html</code>?
I'd prefer JavaScript because I'm not so good with jQuery at the moment, but if it's not possible jQuery would be nice too.</p>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top