ImageMapster (JavaScript)- “onClick” function wont

2019-06-05 22:21发布

问题:

Iam having a problem with a function on ImageMapster. The whole Project works except this little problem:

$('#STADION1').mapster({ 
  mapKey: 'href',
  fillColor:'999999',
  stroke: true,
  strokeWidth:2,
  strokeColor:'3355aa',
  onClick: function(data){
    $test = "";
    $test = $('area').mapster('get');
    document.getElementById('awesome').innerHTML = $test ;
  }
});

So, I have 1000 lines "coordinates" who are all working ("href" is set to '#Number'). What i want to do: if you click on a coordinate, the special "href" value will be shown on a paragraph (with id 'awesome') on my site. The basic script works but there is a tiny mistake in it. If i click on the "first" coordinate nothing will appear in my paragraph. If i click on the "second" coordinate the value of "href" from the first coordinate will appear ... and so on. The latest "click" wont apprea in my paragraph and i dont know why.

To test if my imagemap works, I made a button with id="getAreas". This button got his own "click-funtction". If the Button is clicked, the paragraph (i use on the upper script, too) wil show the current "marked" coordinates. this works perfect. But i want to do it immediatly "onClick" like i describedon the upper side.

$('#getAreas').bind('click',function() {
$test = $('#STADION1').mapster('get');
document.getElementById('awesome').innerHTML = $test;
});

Can you guys help me <3. I dont know how to solve this problem

tl;dr: have a script where i want to show(the value of "href=" the current clicked "areas" of my imagemap. if i use "onClick" it works, but the "latest" area wont give his href-information. If i use the "Button-Script" it works perfect. But i wont use a button. pls help :)