Javascript. Replace HTML content of a Div -


so building website when click on small image displays bigger above. along image being enlarged text overlays image describing , can't seem code change text right. text more complicated uses spans etc have place html code , displays text without formatting.

    // image 1 - football  function change1() {      document          .getelementbyid("mainpic")          .src = "http://files.stv.tv/imagebase/170/623x349/170248-lossiemouth-fc.jpg"      ;      document          .getelementbyid("imagecaption")          .innerhtml = "<span>lossiemouth football club<span class='spacer'></span><br /><span class='spacer'></span>come watch game of football!</span>"      ;  }    // image 2 - football  function change2() {      document          .getelementbyid("mainpic")          .src = "http://www.visitscotland.com/wsimgs/course%206_704927777.jpg[productmain]"      ;      document          .getelementbyid("imagecaption")          .innerhtml = "<span>golf course<span class='spacer'></span><br /><span class='spacer'></span>come play couple rounds of golf!</span>"      ;  }
<div id="imagecaption">      <h2 align="left" style="padding-left: 105px;">          <span>lossiemouth football club              <span class="spacer"></span>              <br />              <span class="spacer"></span>              come watch game of football!          </span>      </h2>  </div>

screen shot examples: before enter image description here after enter image description here

you replacing <h2> tag. move id tag or create new id , use set innerhtml


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -