Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should change :-</p> <pre><code>&lt;b id="boldStuff" /&gt;View large image </code></pre> <p>to following:-</p> <pre><code>&lt;b id="boldStuff"&gt;View large image&lt;/b&gt; </code></pre> <p>Looks like the getElementById does not work well for empty tags If you dont use ending tag. </p> <p>Complete correct source:-</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var curimage = "cottage_small.jpg"; var curtext = "View large image"; function changeSrc() { if (curtext == "View large image"||curimage == "cottage_small.jpg") { document.getElementById("boldStuff").innerHTML = "View small image"; curtext="View small image"; document.getElementById("myImage").src= "cottage_large.jpg"; curimage = "cottage_large.jpg"; } else { document.getElementById("boldStuff").innerHTML = "View large image"; curtext = "View large image"; document.getElementById("myImage").src= "cottage_small.jpg"; curimage = "cottage_small.jpg"; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- Your page here --&gt; &lt;h1&gt; Pink Knoll Properties&lt;/h1&gt; &lt;h2&gt; Single Family Homes&lt;/h2&gt; &lt;p&gt; Cottage:&lt;strong&gt;$149,000&lt;/strong&gt;&lt;br/&gt; 2 bed, 1 bath, 1,189 square feet, 1.11 acres &lt;br/&gt;&lt;br/&gt; &lt;a href="#" onclick="changeSrc()"&gt;&lt;b id="boldStuff"&gt;View large image&lt;/b&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;img id="myImage" src="cottage_small.jpg" alt="Photo of a cottage" /&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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