javascript - How to make text appear in separate div onClick for area of Image Map? -


so have image map , i'm trying make sections of image map clickable when area clicked, text appear on side of image in separate div.

all have image map:

<div id="aside">      <img src="{{ 'image.jpg' | asset_url }}" alt="" usemap="#map" /> <map name="map" id="map"> <area alt="" title="" href="#" shape="rect" coords="33,110,395,217" /></a> <area alt="" title="" href="#" shape="rect" coords="35,222,395,321" /></a> <area alt="" title="" href="#" shape="rect" coords="34,325,395,397" /></a> <area alt="" title="" href="#" shape="rect" coords="34,401,395,565" /></a> <area alt="" title="" href="#" shape="rect" coords="33,571,399,628" /></a> <area alt="" title="" href="#" shape="rect" coords="33,632,394,775" /></a> <area alt="" title="" href="#" shape="rect" coords="409,127,584,275" /></a> <area alt="" title="" href="#" shape="rect" coords="410,281,586,337" /></a> 

i found script want:

 function changetext(value) {  var div = document.getelementbyid("div");  var text = "";  if (value == 1) text += "a"; if (value == 2) text += "b"; if (value == 3) text += "c"; if (value == 4) text += "d"; if (value == 5) text += "e"; if (value == 6) text += "f"; if (value == 7) text += "g";  div.innerhtml = text;} 

and came code:

<a href="javascript: changetext(1);"> <img src="abc.jpg" alt="abc" /> </a> <a href="javascript: changetext(2);"> <img src="abc.jpg" alt="abc" /> </a> <a href="javascript: changetext(3);"> <img src="abc.jpg" alt="abc" /> </a>   <div class="section" id="div"></div> 

the script works tried integrating image map doesn't work. please help! how do this?

i did fiddle. hope you. mouse on image , click on points of coordinates

$(function(){      $("#map area").click(function(){          $("#show_message").html($(this).attr('title'));      });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div id="show_message" style="padding:10px; margin:10px; background:#ff0000;color:#fff">  xxxxxx  </div>  <div id="aside">       <img src="http://www.sfbayshop.com/images/maps/haightstreetmap.gif" alt="" usemap="#map" />  <map name="map" id="map" z-index:-1>  <area alt="" title="text show in div 1" href="#" shape="rect" coords="33,110,395,217" />  <area alt="" title="text show in div 2" href="#" shape="rect" coords="35,222,395,321" />  <area alt="" title="text show in div 3" href="#" shape="rect" coords="34,325,395,397" />  <area alt="" title="text show in div 4" href="#" shape="rect" coords="34,401,395,565" />  <area alt="" title="text show in div 5" href="#" shape="rect" coords="33,571,399,628" />  <area alt="" title="text show in div 6" href="#" shape="rect" coords="33,632,394,775" />  <area alt="" title="text show in div 7" href="#" shape="rect" coords="409,127,584,275" />  <area alt="" title="text show in div 8" href="#" shape="rect" coords="410,281,586,337" />      </map>  </div>

bye


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -