javascript - Switch paragraph using inner html -


i'm trying change image in 1 div , paragraph text in div when clicks on specific co-ordinate on map.

my current code:

js

function myfunction(location_01) {document.getelementbyid("location").innerhtml = "location 1 - paragraph 1";} {document.getelementbyid("overview").innerhtml = "overview 1 - paragraph 1";} {document.getelementbyid("distance").innerhtml = "distance 1 - paragraph 1";}  function myfunction(location_02) {document.getelementbyid("location").innerhtml = "location 2 - paragraph 2";} {document.getelementbyid("overview").innerhtml = "overview 2 - paragraph 2";} {document.getelementbyid("distance").innerhtml = "distance 2 - paragraph 2";}  // etc 

html

<area shape="circle" coords="421,483,13" href="#" alt="alt1" onclick="mm_swapimage('pic_01','','pic1.png',1)";"myfunction('location_01')" /> <area shape="circle" coords="395,475,12" href="#" alt="alt2" onclick="mm_swapimage('pic_01','','pic2.png',1)","myfunction('location_02')"/> 

my images changing fine paragraph change not seeming work.

any appreciated.

you're closing braces , need 1 function.

function myfunction(num) {     num = parseint(num);     document.getelementbyid("location").innerhtml = "location " + num + " - paragraph " + num;     document.getelementbyid("overview").innerhtml = "overview " + num + " - paragraph " + num;     document.getelementbyid("distance").innerhtml = "distance " + num + " - paragraph " + num; } 

also fix following quotes:

<area shape="circle" coords="421,483,13" href="#" alt="alt1" onclick="mm_swapimage('pic_01','','pic1.png',1);myfunction('01')" /> <area shape="circle" coords="395,475,12" href="#" alt="alt2" onclick="mm_swapimage('pic_01','','pic2.png',1),myfunction('02')"/> 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -