Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot set visibility:hidden via JavaScript
    primarykey
    data
    text
    <p>I'm having a bit of trouble getting my head around this thing so I thought it might help to post it here. So here it goes.</p> <p><strong>What I have:</strong> 5 different images in 5 different table cells + a script that I will post below.</p> <p><strong>What I want:</strong> to use the javascript's...</p> <pre><code>document.GetElementById("image ID").style.visibility='visible/hidden' </code></pre> <p>...after a preset time, but, instead of image ID there is a string that gets the ID of the image, and before anyone says anything, I am not using "" for the string that is inside of (). Something like...</p> <pre><code>var n=1; function picID() { pictureID="pic"+n; n=n+1; } </code></pre> <p>...and this way, every time that function is called we get the element ID of "<code>pic1</code>", "<code>pic2</code>", "<code>pic3</code>", etc.</p> <p><strong>What my problem is:</strong> the darn thing won't work. The image styling remains the same as I defined it in the img tag. (<code>style="visibility:hidden"</code>)</p> <p>All image ID's are within the img tag, as it should.</p> <p><strong>Here's the whole code:</strong></p> <pre><code>&lt;script&gt; var m=1; function Show() { if (m==6) {m=1;} feat="feat"+m; **document.getElementById(feat).style.visibility="visible";** m=m+1; setTimeout('Show()', 3000); } window.onload = Show; &lt;/script&gt; &lt;script&gt; var k=1; function Hide() { if (k==6) {k=1;} feate="feat"+k; **document.getElementById(feate).style.visibility="hidden";** k=k+1; setTimeout('Hide()', 3000); } window.onload = Hide; &lt;/script&gt; </code></pre> <p>I've separated the code so it'd easier to spot. From what I've seen the only issue is the bold line within the code. I've tested everything else by replacing the <strong><code>document.getElementById</code></strong> with <strong><code>document.write</code></strong>, so I can see that the custom ID string thingy is working fine. It is. An everything else as well.</p> <p>Any suggestions? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload